fix potential crash. Fixes #2041
This commit is contained in:
1 parent
d5ef0a89db
commit
ac72645cb4
1 file changed
+4
-2
@@ -40,6 +40,8 @@ import net.minecraft.server.MinecraftServer;
|
|||||||
import net.minecraft.server.commands.PerfCommand;
|
import net.minecraft.server.commands.PerfCommand;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
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 class CarpetServer // static for now - easier to handle all around the code, its one anyways
|
||||||
{
|
{
|
||||||
public static MinecraftServer minecraft_server;
|
public static MinecraftServer minecraft_server;
|
||||||
@@ -172,7 +174,7 @@ public class CarpetServer // static for now - easier to handle all around the co
|
|||||||
scriptServer = null;
|
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
|
// 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
|
// 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();
|
if (scriptServer != null) scriptServer.onClose();
|
||||||
// this is a mess, will cleanip onlly when global reference is gone
|
// 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();
|
Vanilla.MinecraftServer_getScriptServer(server).onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user