From 734d691e00eb583e741ee392756cf01365c041ff Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 16 Jan 2013 16:15:50 -0500 Subject: [PATCH] Fix issue where Tree Feller wouldn't work on the base of a player-planted tree. Fixes #524 --- .../nossr50/listeners/WorldListener.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java index fb434cd78..71258fac3 100644 --- a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java @@ -2,11 +2,16 @@ package com.gmail.nossr50.listeners; import java.io.File; import java.util.ArrayList; +import java.util.List; +import org.bukkit.TreeType; +import org.bukkit.block.BlockState; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; +import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.WorldInitEvent; import org.bukkit.event.world.WorldUnloadEvent; @@ -16,6 +21,21 @@ import com.gmail.nossr50.runnables.blockstoreconversion.BlockStoreConversionMain public class WorldListener implements Listener { ArrayList converters = new ArrayList(); + @EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onStructureGrow(StructureGrowEvent event) { + TreeType species = event.getSpecies(); + + if (species == TreeType.BROWN_MUSHROOM || species == TreeType.RED_MUSHROOM) { + return; + } + + List blocks = event.getBlocks(); + + for (BlockState block : blocks) { + mcMMO.placeStore.setFalse(block.getBlock()); + } + } + @EventHandler public void onWorldInit(WorldInitEvent event) { File dataDir = new File(event.getWorld().getWorldFolder(), "mcmmo_data");