Passing events is bad.

This commit is contained in:
GJ 2013-03-28 09:30:49 -04:00
parent 0b6dfad7e5
commit fe89c19969
2 changed files with 10 additions and 13 deletions

View File

@ -58,7 +58,6 @@ public class BlockListener implements Listener {
*/
@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 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);
}
}

View File

@ -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;
}