|
@@ -8,6 +8,7 @@ import org.bukkit.entity.Fish;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.player.PlayerFishEvent;
|
|
import org.bukkit.event.player.PlayerFishEvent;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
+import org.bukkit.metadata.FixedMetadataValue;
|
|
import org.bukkit.plugin.PluginManager;
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
import com.gmail.nossr50.mcMMO;
|
|
@@ -194,4 +195,26 @@ public class EventUtils {
|
|
|
|
|
|
return event;
|
|
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;
|
|
|
|
+ }
|
|
}
|
|
}
|