diff --git a/src/main/java/net/minestom/server/event/EventNode.java b/src/main/java/net/minestom/server/event/EventNode.java index 990483a89..4440f5e98 100644 --- a/src/main/java/net/minestom/server/event/EventNode.java +++ b/src/main/java/net/minestom/server/event/EventNode.java @@ -1,5 +1,7 @@ package net.minestom.server.event; +import com.github.benmanes.caffeine.cache.Cache; +import com.github.benmanes.caffeine.cache.Caffeine; import net.minestom.server.MinecraftServer; import net.minestom.server.event.trait.CancellableEvent; import net.minestom.server.tag.Tag; @@ -190,7 +192,7 @@ public class EventNode { private final Map, ListenerEntry> listenerMap = new ConcurrentHashMap<>(); private final Set> children = new CopyOnWriteArraySet<>(); - private final Map> mappedNode = new ConcurrentHashMap<>(); + private final Map> mappedNode; protected final String name; protected final EventFilter filter; @@ -206,6 +208,9 @@ public class EventNode { this.filter = filter; this.predicate = predicate; this.eventType = filter.eventType(); + + Cache> mapCache = Caffeine.newBuilder().weakKeys().build(); + this.mappedNode = mapCache.asMap(); } /**