mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Rename EventNode#create methods
This commit is contained in:
parent
f6fe41cfe9
commit
8fa4c22d1f
@ -10,12 +10,12 @@ import java.util.function.Predicate;
|
||||
|
||||
public interface EventNode<T extends Event> {
|
||||
|
||||
static <E extends Event> EventNode<E> create(@NotNull Class<E> type) {
|
||||
static <E extends Event> EventNode<E> type(@NotNull Class<E> type) {
|
||||
return new EventNodeImpl<>(type);
|
||||
}
|
||||
|
||||
static EventNode<Event> create() {
|
||||
return create(Event.class);
|
||||
static EventNode<Event> all() {
|
||||
return type(Event.class);
|
||||
}
|
||||
|
||||
static <E extends Event> EventNodeConditional<E> conditional(@NotNull Class<E> type,
|
||||
|
@ -137,16 +137,21 @@ public class PlayerInit {
|
||||
|
||||
// EVENT REGISTERING
|
||||
|
||||
var node = EventNode.create(PlayerEvent.class);
|
||||
var node = EventNode.type(PlayerEvent.class);
|
||||
node.addListener(EventListener.of(PlayerTickEvent.class)
|
||||
.handler(playerTickEvent -> System.out.println("Player tick!"))
|
||||
.expirationCount(2)
|
||||
.build());
|
||||
|
||||
var empty = EventNode.create();
|
||||
var empty = EventNode.all();
|
||||
empty.addListener(PlayerMoveEvent.class, (event) -> {
|
||||
});
|
||||
|
||||
var map = EventNode.list(PlayerEvent.class, Player.class, PlayerEvent::getPlayer);
|
||||
map.addListener(PlayerMoveEvent.class, playerMoveEvent -> {
|
||||
System.out.println("move");
|
||||
});
|
||||
|
||||
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
|
||||
globalEventHandler.addEventCallback(EntityAttackEvent.class, event -> {
|
||||
final Entity source = event.getEntity();
|
||||
|
Loading…
Reference in New Issue
Block a user