Commit b7f5cc97 authored by Benjamin Elsdon's avatar Benjamin Elsdon
Browse files

Added OnGameServerStop EventBus

There is a temporary warning message telling users to ignore the 'No subscribers registered' error. This can be removed once things actually subscribe to it
parent 22781ac6
...@@ -38,12 +38,13 @@ public final class GameServer extends MihoyoKcpServer { ...@@ -38,12 +38,13 @@ public final class GameServer extends MihoyoKcpServer {
private final CommandMap commandMap; private final CommandMap commandMap;
public EventBus OnGameServerTick; public EventBus OnGameServerTick;
public EventBus OnGameServerStop; // TODO public EventBus OnGameServerStop;
public GameServer(InetSocketAddress address) { public GameServer(InetSocketAddress address) {
super(address); super(address);
OnGameServerTick = EventBus.builder().throwSubscriberException(true).build(); OnGameServerTick = EventBus.builder().throwSubscriberException(true).build();
OnGameServerStop = EventBus.builder().throwSubscriberException(true).build();
this.setServerInitializer(new GameServerInitializer(this)); this.setServerInitializer(new GameServerInitializer(this));
this.address = address; this.address = address;
...@@ -173,6 +174,11 @@ public final class GameServer extends MihoyoKcpServer { ...@@ -173,6 +174,11 @@ public final class GameServer extends MihoyoKcpServer {
} }
public void onServerShutdown() { public void onServerShutdown() {
OnGameServerStop.post(new GameServerStopEvent());
Grasscutter.getLogger().info("Ignore the 'No subscribers registered' error");
// TODO: Remove the log once things actually listen to OnGameServerStop.
// I just added it there to prevent people from flooding #support with this error
// Kick and save all players // Kick and save all players
List<GenshinPlayer> list = new ArrayList<>(this.getPlayers().size()); List<GenshinPlayer> list = new ArrayList<>(this.getPlayers().size());
list.addAll(this.getPlayers().values()); list.addAll(this.getPlayers().values());
......
package emu.grasscutter.server.game;
public class GameServerStopEvent {
// Placeholder class for now, probably will get used later
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment