diff --git a/src/main/java/de/doggoat/growableRebalance/listeners/BlockSpreadEventListener.java b/src/main/java/de/doggoat/growableRebalance/listeners/BlockSpreadEventListener.java index a2efa43..56a56ab 100644 --- a/src/main/java/de/doggoat/growableRebalance/listeners/BlockSpreadEventListener.java +++ b/src/main/java/de/doggoat/growableRebalance/listeners/BlockSpreadEventListener.java @@ -31,15 +31,17 @@ public class BlockSpreadEventListener implements Listener { @EventHandler public void onBlockSpread(BlockSpreadEvent e) { + // log.info("BlockSpreadEvent: " + e.getBlock().getType().name()); switch (e.getSource().getType()) { case Material.KELP: this.onKelpSpread(e); break; case Material.BAMBOO: + case Material.BAMBOO_SAPLING: this.onBambooSpread(e); break; default: - log.info("BlockSpreadEvent: Source " + e.getSource().getType()); + // log.info("BlockSpreadEvent: Source " + e.getSource().getType()); break; } } diff --git a/src/main/java/de/doggoat/growableRebalance/listeners/GrowthEventListener.java b/src/main/java/de/doggoat/growableRebalance/listeners/GrowthEventListener.java index 407ad9f..e178a14 100644 --- a/src/main/java/de/doggoat/growableRebalance/listeners/GrowthEventListener.java +++ b/src/main/java/de/doggoat/growableRebalance/listeners/GrowthEventListener.java @@ -1,4 +1,6 @@ package de.doggoat.growableRebalance.listeners; +import de.doggoat.growableRebalance.PlantUtils; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; @@ -6,6 +8,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.plugin.java.JavaPlugin; + +import java.lang.reflect.Array; import java.util.logging.Logger; import java.util.Arrays; import java.util.List; @@ -25,6 +29,16 @@ public class GrowthEventListener implements Listener { @EventHandler public void onStructureGrow(StructureGrowEvent e) { Player p = e.getPlayer(); + Location ground = PlantUtils.getSingleBlockGround(e.getLocation()); + + if (unreplaceableBlocks.contains(ground.getBlock().getType())) { + e.setCancelled(true); + if (p != null) { + p.sendMessage("You cannot grow " + e.getLocation().getBlock().getType() + " on " + ground.getBlock().getType()); + } + return; + } + List forbiddenBlocks = e.getBlocks().stream() .filter(blockState -> unreplaceableBlocks.contains(blockState.getBlock().getType())) .filter(blockState -> dirtBlocks.contains(blockState.getType()))