2014-03-10 20:51:52 +01:00
|
|
|
package com.gmail.nossr50.runnables;
|
|
|
|
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.util.BlockUtils;
|
2014-03-10 20:51:52 +01:00
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
|
|
|
|
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() {
|
2015-03-11 13:31:56 +01:00
|
|
|
if (!mcMMO.getPlaceStore().isTrue(movedBlock.getRelative(direction))) {
|
2014-03-10 20:51:52 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-15 14:22:32 +02:00
|
|
|
if (!BlockUtils.isPistonPiece(movedBlock.getState())) {
|
|
|
|
// The block didn't move
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The sticky piston actually pulled the block so move the PlaceStore data
|
2015-03-11 13:31:56 +01:00
|
|
|
mcMMO.getPlaceStore().setFalse(movedBlock.getRelative(direction));
|
|
|
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
2014-03-10 20:51:52 +01:00
|
|
|
}
|
|
|
|
}
|