Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jckf/pistonfix

Restore pre-1.8 behavior to BlockPistonRetractEvent.
https://github.com/jckf/pistonfix

Last synced: 13 days ago
JSON representation

Restore pre-1.8 behavior to BlockPistonRetractEvent.

Awesome Lists containing this project

README

        

# PistonFix

Behavior of the BlockPistonRetractEvent was changed when Spigot updated
CraftBukkit to Minecraft 1.8. This new behavior can be very confusing, and
outright breaks existing plugins. See
[SPIGOT-117](https://hub.spigotmc.org/jira/browse/SPIGOT-117).

The problem is an additional trigger of BlockPistonRetractEvent for non-sticky
pistons, causing plugins to see the same piston retract twice in a row. This
plugin works around that by cancelling the second event in a LOWEST priority
handler, and then uncancelling it again in a MONITOR priority event handler.
This means plugins running on the same server as PistonFix will still see two
BlockPistonRetractEvents, but the second one will be cancelled for all handlers
that are not at LOWEST priority. Behavior for such handlers is undefined.

In summary, this means you can ignore the extraneous event by setting
`ignoreCancelled=true` on your BlockPistonRetractEvent handler like so:

```java
@EventHandler(ignoreCancelled=true)
public void onBlockPistonRetract(BlockPistonRetractEvent) {
// I will only trigger once per actual retract :)
}
```