From d1f774892c110d6613707f2d4aa906fe6df7f129 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Fri, 26 May 2023 23:26:49 -0400 Subject: [PATCH] Fix event calling & canceling --- src/main/java/emu/grasscutter/server/event/Event.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/server/event/Event.java b/src/main/java/emu/grasscutter/server/event/Event.java index 4392b133b..6e4df304e 100644 --- a/src/main/java/emu/grasscutter/server/event/Event.java +++ b/src/main/java/emu/grasscutter/server/event/Event.java @@ -14,10 +14,12 @@ public abstract class Event { /** Cancels the event if possible. */ public void cancel() { if (this instanceof Cancellable) this.cancelled = true; + else throw new UnsupportedOperationException("Event is not cancellable."); } /** Pushes this event to all listeners. */ public void call() { - Grasscutter.getPluginManager().invokeEvent(this); + var pluginManager = Grasscutter.getPluginManager(); + if (pluginManager != null) pluginManager.invokeEvent(this); } }