Fix the issues with sticky pistons and slime blocks

This is a fix for issues #2419 and #2494
This commit is contained in:
TfT_02
2015-03-21 16:07:05 +01:00
parent 4aeda6e9e8
commit cfa0daefc5
6 changed files with 53 additions and 45 deletions

View File

@ -9,7 +9,6 @@ import org.bukkit.entity.Fish;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.PluginManager;
import com.gmail.nossr50.mcMMO;
@ -280,26 +279,4 @@ public class EventUtils {
return event;
}
/**
* There is a bug in CraftBukkit that causes piston events to
* fire multiple times. Check this method to see if the piston event
* should be processed.
*
* @param block Block object of the piston block
* @param isExtendEvent should be true when called from BlockPistonExtendEvent
*
* @return true if the PistonEvent should be processed, false otherwise
*/
public static boolean shouldProcessEvent(Block block, boolean isExtendEvent) {
String pistonAction = isExtendEvent ? "EXTEND" : "RETRACT";
String lastAction = block.hasMetadata(mcMMO.pistonDataKey) ? block.getMetadata(mcMMO.pistonDataKey).get(0).asString() : "";
if (!lastAction.equals(pistonAction)) {
block.setMetadata(mcMMO.pistonDataKey, new FixedMetadataValue(mcMMO.p, pistonAction));
return true;
}
return false;
}
}