diff --git a/core/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java b/core/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java index d639695a..822c33eb 100644 --- a/core/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java +++ b/core/src/main/java/io/github/dre2n/dungeonsxl/listener/BlockListener.java @@ -35,6 +35,7 @@ import io.github.dre2n.dungeonsxl.world.DGameWorld; import io.github.dre2n.dungeonsxl.world.DInstanceWorld; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -50,7 +51,7 @@ import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.SignChangeEvent; /** - * @author Frank Baumann, Milan Albrecht, Daniel Saukel + * @author Frank Baumann, Milan Albrecht, Daniel Saukel, Wooyoung Son */ public class BlockListener implements Listener { @@ -64,6 +65,28 @@ public class BlockListener implements Listener { } } + @EventHandler + public void onBreakWithSignOnIt(BlockBreakEvent event){ + Block block = event.getBlock(); + Player player = event.getPlayer(); + + Block blockAbove = block.getRelative(BlockFace.UP); + //get the above block and return if there is nothing + if(blockAbove == null) + return; + + //return if above block is not a sign + if(blockAbove.getType() != Material.SIGN_POST && blockAbove.getType() != Material.WALL_SIGN) + return; + + //let onBreak() method to handle the sign + BlockBreakEvent bbe = new BlockBreakEvent(blockAbove, player); + onBreak(bbe); + + //follow the onBreak() + event.setCancelled(bbe.isCancelled()); + } + @EventHandler(priority = EventPriority.HIGH) public void onBreak(BlockBreakEvent event) { Block block = event.getBlock();