Permalink
Browse files

Passing events is bad.

  • Loading branch information...
1 parent 0b6dfad commit fe89c19969a082803bf32109faf126db896f9f60 @gmcferrin gmcferrin committed Mar 28, 2013
@@ -58,7 +58,6 @@ public BlockListener(final mcMMO plugin) {
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
-
List<Block> 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 void onBlockPistonExtend(BlockPistonExtendEvent event) {
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);
}
}
@@ -2,28 +2,26 @@
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;
}

0 comments on commit fe89c19

Please sign in to comment.