Remove unnecessary #callEvent override in Entity

This commit is contained in:
Felix Cravic 2020-12-09 22:18:11 +01:00
parent 08f7b1c715
commit 30d257c847
2 changed files with 10 additions and 10 deletions

View File

@ -641,16 +641,6 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
return eventCallbacks;
}
@Override
public <E extends Event> void callEvent(@NotNull Class<E> 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.
*

View File

@ -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<E> 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);
}
}
}
/**