Now, I am very happy with sponge’s new event system, the only thing I don’t like is they don’t appear to have a list of what events correspond to old events…
So my question is, what events correspond to the following:
- PlayerInteractEvent (including with air)
- PlayerMoveEvent
Also, can someone explain how the new cause system works?
Great thanks for the help!
For all types of interaction, there’s InteractEvent
. If you want all block interactions, see InteractBlockEvent
and for entities, InteractEntityEvent
.
Because these events are not player specific, you have to see what caused the event to fire in the first place.
If you’re only interested in player-caused events, do something like this:
@Listener
public void onInteractBlock(InteractBlockEvent event) {
Optional<Player> optPlayer = event.getCause().first(Player.class);
if (!optPlayer.isPresent()) {
return; // Don't care about non-player caused events
}
Player player = optPlayer.get();
// Do something here
}
@simon816
What about PlayerPickupItemEvent and PlayerDropItemEvent?
EDIT:
Nevermind… got the,