Skip to content

Commit

Permalink
Fix a crash caused by a server crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
melontini committed May 9, 2024
1 parent 4ecff04 commit d278b7c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public class ServerLifecycle {

public static void init() {
ServerLifecycleEvents.SERVER_STARTED.register(server -> runVoid(SERVER_STARTED, server.getOverworld(), () -> forWorld(server.getOverworld())));
ServerLifecycleEvents.SERVER_STOPPING.register(server -> runVoid(SERVER_STOPPING, server.getOverworld(), () -> forWorld(server.getOverworld())));
ServerLifecycleEvents.SERVER_STOPPING.register(server -> {
if (server.getOverworld() != null) //If the server crashes at a specific moment, this event may be triggered, but the worlds are not yet loaded.
runVoid(SERVER_STOPPING, server.getOverworld(), () -> forWorld(server.getOverworld()));
});

ServerWorldEvents.LOAD.register((server, world) -> runVoid(WORLD_LOAD, world, () -> forWorld(world)));
ServerWorldEvents.UNLOAD.register((server, world) -> runVoid(WORLD_UNLOAD, world, () -> forWorld(world)));
Expand Down

0 comments on commit d278b7c

Please sign in to comment.