Skip to content

Commit

Permalink
Fixed tree growth still being logged when disabled via config
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Aug 23, 2023
1 parent af35a98 commit 45d4642
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -31,12 +33,16 @@ protected void onBlockFertilize(BlockFertilizeEvent event) {

Location location = block.getLocation();
List<BlockState> 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();
Expand Down

0 comments on commit 45d4642

Please sign in to comment.