mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 17:37:42 +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> {
|
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);
|
return new EventNodeImpl<>(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EventNode<Event> create() {
|
static EventNode<Event> all() {
|
||||||
return create(Event.class);
|
return type(Event.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
static <E extends Event> EventNodeConditional<E> conditional(@NotNull Class<E> type,
|
static <E extends Event> EventNodeConditional<E> conditional(@NotNull Class<E> type,
|
||||||
|
@ -137,16 +137,21 @@ public class PlayerInit {
|
|||||||
|
|
||||||
// EVENT REGISTERING
|
// EVENT REGISTERING
|
||||||
|
|
||||||
var node = EventNode.create(PlayerEvent.class);
|
var node = EventNode.type(PlayerEvent.class);
|
||||||
node.addListener(EventListener.of(PlayerTickEvent.class)
|
node.addListener(EventListener.of(PlayerTickEvent.class)
|
||||||
.handler(playerTickEvent -> System.out.println("Player tick!"))
|
.handler(playerTickEvent -> System.out.println("Player tick!"))
|
||||||
.expirationCount(2)
|
.expirationCount(2)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
var empty = EventNode.create();
|
var empty = EventNode.all();
|
||||||
empty.addListener(PlayerMoveEvent.class, (event) -> {
|
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 globalEventHandler = MinecraftServer.getGlobalEventHandler();
|
||||||
globalEventHandler.addEventCallback(EntityAttackEvent.class, event -> {
|
globalEventHandler.addEventCallback(EntityAttackEvent.class, event -> {
|
||||||
final Entity source = event.getEntity();
|
final Entity source = event.getEntity();
|
||||||
|
Loading…
Reference in New Issue
Block a user