Merge pull request #2489 from isokissa3/master

Fixed duplication Bug #2489 
Tentatively pulling this as I assume its valid.
This commit is contained in:
t00thpick1 2015-03-18 03:51:35 -04:00
commit 7ce72bafb0
2 changed files with 17 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@ -98,14 +99,23 @@ public class BlockListener implements Listener {
return;
}
if (!event.isSticky()) {
// Don't even work, return ALLWAYS false xD
/*if (!event.isSticky()){
return;
}*/
// Sticky piston return PISTON_MOVING_PIECE and normal piston PISTON_BASE, so mess stuff
if (event.getBlock().getType() != Material.PISTON_MOVING_PIECE) {
return;
}
Block movedBlock = event.getRetractLocation().getBlock();
// event.getRetractLocation() return wrong side and too far away
// Get opposite direction so we get correct block, so mess stuff
Block movedBlock = event.getBlock().getRelative(event.getDirection().getOppositeFace());
// Needed only because under some circumstances Minecraft doesn't move the block
new StickyPistonTrackerTask(event.getDirection(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
// Opposite side here too
new StickyPistonTrackerTask(event.getDirection().getOppositeFace(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
}
/**

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.runnables;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.scheduler.BukkitRunnable;
@ -20,7 +21,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
@Override
public void run() {
if (!mcMMO.getPlaceStore().isTrue(movedBlock)) {
if (!mcMMO.getPlaceStore().isTrue(movedBlock.getRelative(direction))) {
return;
}
@ -30,7 +31,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
}
// The sticky piston actually pulled the block so move the PlaceStore data
mcMMO.getPlaceStore().setFalse(movedBlock);
mcMMO.getPlaceStore().setTrue(movedBlock.getRelative(direction));
mcMMO.getPlaceStore().setFalse(movedBlock.getRelative(direction));
mcMMO.getPlaceStore().setTrue(movedBlock);
}
}