From 45d464208631aa6172bafcfc5133ffae6ba0a5cf Mon Sep 17 00:00:00 2001 From: Intelli Date: Wed, 23 Aug 2023 16:21:37 -0600 Subject: [PATCH] Fixed tree growth still being logged when disabled via config --- .../listener/block/BlockFertilizeListener.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/coreprotect/listener/block/BlockFertilizeListener.java b/src/main/java/net/coreprotect/listener/block/BlockFertilizeListener.java index ebe48506..325c608b 100644 --- a/src/main/java/net/coreprotect/listener/block/BlockFertilizeListener.java +++ b/src/main/java/net/coreprotect/listener/block/BlockFertilizeListener.java @@ -4,11 +4,13 @@ import java.util.Locale; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockFertilizeEvent; @@ -18,7 +20,7 @@ public final class BlockFertilizeListener extends Queue implements Listener { - @EventHandler + @EventHandler(priority = EventPriority.MONITOR) protected void onBlockFertilize(BlockFertilizeEvent event) { if (event.isCancelled()) { return; @@ -31,12 +33,16 @@ protected void onBlockFertilize(BlockFertilizeEvent event) { Location location = block.getLocation(); List blocks = event.getBlocks(); + if (Tag.SAPLINGS.isTagged(block.getType()) && (!Config.getConfig(location.getWorld()).TREE_GROWTH || (blocks.size() == 1 && blocks.get(0).getLocation().equals(location)))) { return; } if (block.getType().name().toLowerCase(Locale.ROOT).contains("mushroom") && (!Config.getConfig(location.getWorld()).MUSHROOM_GROWTH || (blocks.size() == 1 && blocks.get(0).getLocation().equals(location)))) { return; } + if (block.getType() == Material.AIR && blocks.size() > 1 && Tag.LOGS.isTagged(blocks.get(1).getType()) && !Config.getConfig(location.getWorld()).TREE_GROWTH) { + return; + } String user = "#bonemeal"; Player player = event.getPlayer();