mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-29 16:31:51 +00:00
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
This commit is contained in:
parent
22781ac6e7
commit
b7f5cc9748
@ -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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package emu.grasscutter.server.game;
|
||||||
|
|
||||||
|
public class GameServerStopEvent {
|
||||||
|
// Placeholder class for now, probably will get used later
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user