Game Events
Catching Events
To catch an event, you can use the executeEvents
method.
The index 0 of the events array will be a GameEvent
enum. The index 1 will be the event itself.
Here's an example of how you can listen to an event where the holder attacks another player:
@Override
public Object executeEvents(Object... events) {
if (!GameEvent.HOLDER_DAMAGE_PLAYER.equals(events[0])) return null;
EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) events[1];
Player victim = (Player) event.getEntity();
// Do stuff with the event.
return null;
}
Last updated