From 30d257c8470271d34f44906b905f298de4a3027c Mon Sep 17 00:00:00 2001 From: Felix Cravic Date: Wed, 9 Dec 2020 22:18:11 +0100 Subject: [PATCH] Remove unnecessary #callEvent override in Entity --- src/main/java/net/minestom/server/entity/Entity.java | 10 ---------- .../minestom/server/event/handler/EventHandler.java | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/minestom/server/entity/Entity.java b/src/main/java/net/minestom/server/entity/Entity.java index 90fc86e38..bb04a6722 100644 --- a/src/main/java/net/minestom/server/entity/Entity.java +++ b/src/main/java/net/minestom/server/entity/Entity.java @@ -641,16 +641,6 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P return eventCallbacks; } - @Override - public void callEvent(@NotNull Class eventClass, @NotNull E event) { - EventHandler.super.callEvent(eventClass, event); - - // Call the same event for the current entity instance - if (instance != null) { - instance.callEvent(eventClass, event); - } - } - /** * Each entity has an unique id (server-wide) which will change after a restart. * diff --git a/src/main/java/net/minestom/server/event/handler/EventHandler.java b/src/main/java/net/minestom/server/event/handler/EventHandler.java index 23508cedb..47080e812 100644 --- a/src/main/java/net/minestom/server/event/handler/EventHandler.java +++ b/src/main/java/net/minestom/server/event/handler/EventHandler.java @@ -1,8 +1,10 @@ package net.minestom.server.event.handler; +import net.minestom.server.entity.Entity; import net.minestom.server.event.CancellableEvent; import net.minestom.server.event.Event; import net.minestom.server.event.EventCallback; +import net.minestom.server.instance.Instance; import net.minestom.server.utils.validate.Check; import org.jetbrains.annotations.NotNull; @@ -92,6 +94,14 @@ public interface EventHandler { for (EventCallback eventCallback : eventCallbacks) { eventCallback.run(event); } + + // Call the same event for the current entity instance + if (this instanceof Entity) { + final Instance instance = ((Entity) this).getInstance(); + if (instance != null) { + instance.callEvent(eventClass, event); + } + } } /**