mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Remove EventNodeList.java
This commit is contained in:
parent
3727f3f954
commit
493c397efe
@ -39,10 +39,6 @@ public class EventNode<T extends Event> {
|
||||
return conditional(filter, (e, h) -> predicate.test(h));
|
||||
}
|
||||
|
||||
public static <E extends Event, H> EventNodeList<E, H> list(@NotNull EventFilter<E, H> filter) {
|
||||
return new EventNodeList<>(filter);
|
||||
}
|
||||
|
||||
private volatile String name = "unknown";
|
||||
|
||||
private final Map<Class<? extends T>, List<EventListener<T>>> listenerMap = new ConcurrentHashMap<>();
|
||||
|
@ -1,29 +0,0 @@
|
||||
package net.minestom.server.event;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class EventNodeList<T extends Event, H> extends EventNode<T> {
|
||||
|
||||
private final List<H> entries = new CopyOnWriteArrayList<>();
|
||||
|
||||
protected EventNodeList(EventFilter<T, H> filter) {
|
||||
super(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean condition(@NotNull T event) {
|
||||
final var eventHandler = filter.getHandler(event);
|
||||
return entries.contains(eventHandler);
|
||||
}
|
||||
|
||||
public void addEntry(@NotNull H handler) {
|
||||
this.entries.add(handler);
|
||||
}
|
||||
|
||||
public void removeEntry(@NotNull H handler) {
|
||||
this.entries.remove(handler);
|
||||
}
|
||||
}
|
@ -146,9 +146,16 @@ public class PlayerInit {
|
||||
node.setName("node");
|
||||
node.addListener(EventListener.builder(PlayerTickEvent.class)
|
||||
.handler(playerTickEvent -> System.out.println("Player tick!"))
|
||||
.expirationCount(2)
|
||||
.expirationCount(50)
|
||||
.build());
|
||||
|
||||
empty.addChild(node);
|
||||
node.call(new PlayerTickEvent(null));
|
||||
empty.call(new PlayerTickEvent(null));
|
||||
empty.removeChild(node);
|
||||
node.call(new PlayerTickEvent(null));
|
||||
empty.call(new PlayerTickEvent(null));
|
||||
|
||||
/*
|
||||
* Map a node to a single element
|
||||
*
|
||||
@ -162,10 +169,6 @@ public class PlayerInit {
|
||||
conditional.addListener(EventListener.of(PlayerMoveEvent.class, (event) ->
|
||||
System.out.println("creative player moved")));
|
||||
|
||||
var list = EventNode.list(EventFilter.PLAYER);
|
||||
list.addListener(EventListener.of(PlayerMoveEvent.class, event ->
|
||||
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