From 6842403e5a36d100aeffe988de9fd90597e2aa90 Mon Sep 17 00:00:00 2001 From: Jonny D Date: Sat, 26 May 2012 19:02:54 +0100 Subject: [PATCH] The method pistonRetract went missing. Here it is again. --- .../citadel/listener/BlockListener.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/plugins/citadel-paper/src/com/untamedears/citadel/listener/BlockListener.java b/plugins/citadel-paper/src/com/untamedears/citadel/listener/BlockListener.java index 7e6c607b5..2f2b4f312 100644 --- a/plugins/citadel-paper/src/com/untamedears/citadel/listener/BlockListener.java +++ b/plugins/citadel-paper/src/com/untamedears/citadel/listener/BlockListener.java @@ -129,7 +129,8 @@ public class BlockListener extends PluginConsumer implements Listener { if (block.getType() == Material.AIR) break; - // Get the bottom half of the door + // Get the bottom half of the door because bottom half + // is the part that's stored in the database as reinforced if(block.getType() == Material.WOODEN_DOOR || block.getType() == Material.IRON_DOOR){ Door door = (Door) block.getState().getData(); if(door.isTopHalf()){ @@ -146,6 +147,36 @@ public class BlockListener extends PluginConsumer implements Listener { } } + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) + public void pistonRetract(BlockPistonRetractEvent bpre) { + Block piston = bpre.getBlock(); + BlockState state = piston.getState(); + MaterialData data = state.getData(); + BlockFace direction = null; + + // Check the block it pushed directly + if (data instanceof PistonBaseMaterial) { + direction = ((PistonBaseMaterial) data).getFacing(); + } + + if (direction == null) return; + + // the block that the piston moved + Block moved = piston.getRelative(direction, 2); + if (moved.getType() == Material.WOODEN_DOOR || moved.getType() == Material.IRON_DOOR_BLOCK) { + Block below = moved.getRelative(BlockFace.DOWN).getRelative(direction.getOppositeFace()); + + if (plugin.dao.findReinforcement(below) != null) { + bpre.setCancelled(true); + return; + } + } + + if (plugin.dao.findReinforcement(moved) != null) { + bpre.setCancelled(true); + } + } + private static final Material matfire = Material.FIRE; @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void blockBurn(BlockBurnEvent bbe) {