From ebb8d03985046f04021445ac7e8ec82be3ab81e5 Mon Sep 17 00:00:00 2001 From: TheMode Date: Sat, 14 Aug 2021 02:56:34 +0200 Subject: [PATCH] Fix `getEventMapping` --- .../net/minestom/server/event/EventNode.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/minestom/server/event/EventNode.java b/src/main/java/net/minestom/server/event/EventNode.java index e805e0818..c9c8e828e 100644 --- a/src/main/java/net/minestom/server/event/EventNode.java +++ b/src/main/java/net/minestom/server/event/EventNode.java @@ -577,17 +577,21 @@ public class EventNode { private static List> getEventMapping(Class eventClass) { return HANDLER_SUPPLIERS.computeIfAbsent(eventClass, clazz -> { List> result = new ArrayList<>(); - if (EntityEvent.class.isAssignableFrom(clazz)) { - result.add(e -> ((EntityEvent) e).getEntity()); - } else if (PlayerEvent.class.isAssignableFrom(clazz)) { + if (PlayerEvent.class.isAssignableFrom(clazz)) { result.add(e -> ((PlayerEvent) e).getPlayer()); - } else if (ItemEvent.class.isAssignableFrom(clazz)) { + } else if (EntityEvent.class.isAssignableFrom(clazz)) { + result.add(e -> ((EntityEvent) e).getEntity()); + } + if (ItemEvent.class.isAssignableFrom(clazz)) { result.add(e -> ((ItemEvent) e).getItemStack()); - } else if (InstanceEvent.class.isAssignableFrom(clazz)) { + } + if (InstanceEvent.class.isAssignableFrom(clazz)) { result.add(e -> ((InstanceEvent) e).getInstance()); - } else if (InventoryEvent.class.isAssignableFrom(clazz)) { + } + if (InventoryEvent.class.isAssignableFrom(clazz)) { result.add(e -> ((InventoryEvent) e).getInventory()); - } else if (BlockEvent.class.isAssignableFrom(clazz)) { + } + if (BlockEvent.class.isAssignableFrom(clazz)) { result.add(e -> ((BlockEvent) e).getBlock()); } return result;