alex9849 / advanced-region-market

A Bukkit/Spigot plugin for renting/selling WorldGuard regions
https://www.spigotmc.org/resources/advancedregionmarket.58732/
69 stars 45 forks source link

Addition of BlockFertilizeEvent #151

Open Kai-Wels opened 1 year ago

Kai-Wels commented 1 year ago

Hello Alex,

for a server that uses your plugin I made a small change to the source code, that I believe would benefit most use cases. I am adding blocks that generate because of the use of bonemeal to the list of blocks placed by the player. This is helpful if players want to farm on a hotel region. Because I made my changes inside of a gitlab repo I cant issue a pull request, therefor I will just mention the code changes I made.

In the file "BlockModifyListener" I added following lines:


 @EventHandler(priority = EventPriority.HIGHEST)
    public void addGeneratedBlock(BlockFertilizeEvent event) {
        if (event.isCancelled()) {
            return;
        }
        if (AdvancedRegionMarket.getInstance().getRegionManager() == null) {
            return;
        }

        List<Region> locRegions = AdvancedRegionMarket.getInstance().getRegionManager().getRegionsByLocation(event.getBlock().getLocation());

        for (Region region : locRegions) {
            if (region.isHotel()) {
                if (region.isSold()) {
                    for (BlockState block : event.getBlocks()){
                        region.addBuiltBlock(block.getLocation());
                    }
                }
            }
        }
    }

Because I believe this feature would benefit a lot of Players I hope you consider adding it to your code.

Thank you for your amazing work.

Best regards, Kai