2014-03-10 20:51:52 +01:00
|
|
|
package com.gmail.nossr50.runnables;
|
|
|
|
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
import org.bukkit.block.PistonMoveReaction;
|
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.util.BlockUtils;
|
|
|
|
|
|
|
|
public class StickyPistonTrackerTask extends BukkitRunnable {
|
|
|
|
private BlockFace direction;
|
2014-03-11 13:28:56 +01:00
|
|
|
private Block block;
|
2014-03-10 20:51:52 +01:00
|
|
|
private Block movedBlock;
|
|
|
|
|
2014-03-11 13:28:56 +01:00
|
|
|
public StickyPistonTrackerTask(BlockFace direction, Block block, Block movedBlock) {
|
2014-03-10 20:51:52 +01:00
|
|
|
this.direction = direction;
|
2014-03-11 13:28:56 +01:00
|
|
|
this.block = block;
|
2014-03-10 20:51:52 +01:00
|
|
|
this.movedBlock = movedBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (!BlockUtils.shouldBeWatched(movedBlock.getState()) || movedBlock.getPistonMoveReaction() != PistonMoveReaction.MOVE || !mcMMO.getPlaceStore().isTrue(movedBlock)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mcMMO.getPlaceStore().setFalse(movedBlock);
|
2014-03-11 13:28:56 +01:00
|
|
|
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
2014-03-10 20:51:52 +01:00
|
|
|
}
|
|
|
|
}
|