Fix HTTP server preventing server stop

This commit is contained in:
Alessandro Proto 2024-09-01 13:46:03 +02:00
parent fdcd730819
commit 59604a1997
2 changed files with 7 additions and 1 deletions

View file

@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10
loader_version=0.16.3
# Mod Properties
mod_version=1.6.0
mod_version=1.6.1
maven_group=cc.reconnected
archives_base_name=rcc-server

View file

@ -6,6 +6,7 @@ import cc.reconnected.server.database.PlayerTable;
import cc.reconnected.server.events.PlayerWelcome;
import cc.reconnected.server.http.ServiceServer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
@ -93,6 +94,11 @@ public class RccServer implements ModInitializer {
}
});
ServerLifecycleEvents.SERVER_STOPPING.register(server -> {
LOGGER.info("Stopping HTTP services");
serviceServer.httpServer().stop(0);
});
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
currentPlayerCount = server.getCurrentPlayerCount() + 1;
var player = handler.getPlayer();