diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 3e0fcd33a..469f0c7a4 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -58,7 +58,6 @@ public class BlockListener implements Listener { */ @EventHandler(priority = EventPriority.MONITOR) public void onBlockPistonExtend(BlockPistonExtendEvent event) { - List blocks = event.getBlocks(); BlockFace direction = event.getDirection(); Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished @@ -89,7 +88,7 @@ public class BlockListener implements Listener { public void onBlockPistonRetract(BlockPistonRetractEvent event) { if (event.isSticky()) { // Needed only because under some circumstances Minecraft doesn't move the block - new StickyPistonTrackerTask(event).runTaskLater(plugin, 2); + new StickyPistonTrackerTask(event.getDirection(), event.getBlock()).runTaskLater(plugin, 2); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java index 76a5716a3..14530b054 100644 --- a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java @@ -2,28 +2,26 @@ package com.gmail.nossr50.runnables; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.block.BlockFace; import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.mcMMO; public class StickyPistonTrackerTask extends BukkitRunnable { - BlockPistonRetractEvent event; + private BlockFace direction; + private Block block; - public StickyPistonTrackerTask(BlockPistonRetractEvent event) { - this.event = event; + public StickyPistonTrackerTask(BlockFace direction, Block block) { + this.direction = direction; + this.block = block; } @Override public void run() { - Block newBlock = event.getBlock().getRelative(event.getDirection()); - Block originalBlock = newBlock.getRelative(event.getDirection()); + Block newBlock = block.getRelative(direction); + Block originalBlock = newBlock.getRelative(direction); - if (originalBlock.getType() != Material.AIR) { - return; - } - - if (!mcMMO.placeStore.isTrue(originalBlock)) { + if (originalBlock.getType() != Material.AIR || !mcMMO.placeStore.isTrue(originalBlock)) { return; }