mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-20 07:02:32 +01:00
Keep using GlobalEventHandler
This commit is contained in:
parent
a585e4e45b
commit
d9b26f84d3
@ -8,8 +8,6 @@ import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.data.SerializableData;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.event.EventNode;
|
||||
import net.minestom.server.event.GlobalEventHandler;
|
||||
import net.minestom.server.exception.ExceptionManager;
|
||||
import net.minestom.server.extensions.Extension;
|
||||
@ -125,7 +123,6 @@ public final class MinecraftServer {
|
||||
|
||||
private static ExtensionManager extensionManager;
|
||||
|
||||
private static final EventNode<Event> GLOBAL_EVENT_NODE = EventNode.all("global");
|
||||
private static final GlobalEventHandler GLOBAL_EVENT_HANDLER = new GlobalEventHandler();
|
||||
|
||||
private static UpdateManager updateManager;
|
||||
@ -300,18 +297,11 @@ public final class MinecraftServer {
|
||||
* Used to register event callback at a global scale.
|
||||
*
|
||||
* @return the global event handler
|
||||
* @deprecated use {@link #getGlobalEventNode()}
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public static GlobalEventHandler getGlobalEventHandler() {
|
||||
public static @NotNull GlobalEventHandler getGlobalEventHandler() {
|
||||
return GLOBAL_EVENT_HANDLER;
|
||||
}
|
||||
|
||||
public static @NotNull EventNode<Event> getGlobalEventNode() {
|
||||
return GLOBAL_EVENT_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the manager handling all incoming packets
|
||||
*
|
||||
|
@ -157,7 +157,7 @@ public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, Da
|
||||
Entity.ENTITY_BY_UUID.put(uuid, this);
|
||||
|
||||
this.eventNode = EventNode.type("entity-" + uuid, EventFilter.ENTITY);
|
||||
MinecraftServer.getGlobalEventNode().map(this, eventNode);
|
||||
MinecraftServer.getGlobalEventHandler().map(this, eventNode);
|
||||
}
|
||||
|
||||
public Entity(@NotNull EntityType entityType) {
|
||||
|
@ -6,10 +6,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class EventDispatcher {
|
||||
|
||||
public static void call(@NotNull Event event) {
|
||||
MinecraftServer.getGlobalEventNode().call(event);
|
||||
MinecraftServer.getGlobalEventHandler().call(event);
|
||||
}
|
||||
|
||||
public static void callCancellable(@NotNull CancellableEvent event, @NotNull Runnable successCallback) {
|
||||
MinecraftServer.getGlobalEventNode().callCancellable(event, successCallback);
|
||||
MinecraftServer.getGlobalEventHandler().callCancellable(event, successCallback);
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,23 @@
|
||||
package net.minestom.server.event;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.event.handler.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Object containing all the global event listeners.
|
||||
*
|
||||
* @deprecated use {@link MinecraftServer#getGlobalEventNode()}
|
||||
*/
|
||||
public final class GlobalEventHandler extends EventNode<Event> {
|
||||
public GlobalEventHandler() {
|
||||
super("global", EventFilter.ALL, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #addListener(Class, Consumer)}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class GlobalEventHandler implements EventHandler<Event> {
|
||||
|
||||
private final EventNode<Event> node = EventNode.all("global-handler");
|
||||
|
||||
{
|
||||
MinecraftServer.getGlobalEventNode().addChild(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EventNode<Event> getEventNode() {
|
||||
return node;
|
||||
public <V extends Event> boolean addEventCallback(@NotNull Class<V> eventClass, @NotNull EventCallback<V> eventCallback) {
|
||||
addListener(eventClass, eventCallback::run);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
||||
this.worldBorder = new WorldBorder(this);
|
||||
|
||||
this.eventNode = EventNode.type("instance-" + uniqueId, EventFilter.INSTANCE);
|
||||
MinecraftServer.getGlobalEventNode().map(this, eventNode);
|
||||
MinecraftServer.getGlobalEventHandler().map(this, eventNode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user