diff --git a/src/main/java/carpet/CarpetServer.java b/src/main/java/carpet/CarpetServer.java index ac102ace..65ffb8ad 100644 --- a/src/main/java/carpet/CarpetServer.java +++ b/src/main/java/carpet/CarpetServer.java @@ -40,6 +40,8 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.commands.PerfCommand; import net.minecraft.server.level.ServerPlayer; +import javax.annotation.Nullable; + public class CarpetServer // static for now - easier to handle all around the code, its one anyways { public static MinecraftServer minecraft_server; @@ -172,7 +174,7 @@ public class CarpetServer // static for now - easier to handle all around the co scriptServer = null; } - public static void onServerClosed(MinecraftServer server) + public static void onServerClosed(@Nullable MinecraftServer server) { // this for whatever reason gets called multiple times even when joining on SP // so we allow to pass multiple times gating it only on existing server ref @@ -180,7 +182,7 @@ public class CarpetServer // static for now - easier to handle all around the co { if (scriptServer != null) scriptServer.onClose(); // this is a mess, will cleanip onlly when global reference is gone - if (!Vanilla.MinecraftServer_getScriptServer(server).stopAll) { + if (server != null && !Vanilla.MinecraftServer_getScriptServer(server).stopAll) { Vanilla.MinecraftServer_getScriptServer(server).onClose(); }