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

Added OnGameServerStartFinish EventBus

Removed those temporary warning messages as I figured out how to disable them
parent b7f5cc97
...@@ -3,7 +3,6 @@ package emu.grasscutter.server.game; ...@@ -3,7 +3,6 @@ package emu.grasscutter.server.game;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import emu.grasscutter.GenshinConstants; import emu.grasscutter.GenshinConstants;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
...@@ -20,7 +19,6 @@ import emu.grasscutter.game.shop.ShopManager; ...@@ -20,7 +19,6 @@ import emu.grasscutter.game.shop.ShopManager;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
import emu.grasscutter.netty.MihoyoKcpServer; import emu.grasscutter.netty.MihoyoKcpServer;
import jdk.internal.event.Event;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
public final class GameServer extends MihoyoKcpServer { public final class GameServer extends MihoyoKcpServer {
...@@ -37,14 +35,16 @@ public final class GameServer extends MihoyoKcpServer { ...@@ -37,14 +35,16 @@ public final class GameServer extends MihoyoKcpServer {
private final DungeonManager dungeonManager; private final DungeonManager dungeonManager;
private final CommandMap commandMap; private final CommandMap commandMap;
public EventBus OnGameServerStartFinish;
public EventBus OnGameServerTick; public EventBus OnGameServerTick;
public EventBus OnGameServerStop; public EventBus OnGameServerStop;
public GameServer(InetSocketAddress address) { public GameServer(InetSocketAddress address) {
super(address); super(address);
OnGameServerTick = EventBus.builder().throwSubscriberException(true).build(); OnGameServerStartFinish = EventBus.builder().throwSubscriberException(true).logNoSubscriberMessages(false).build();
OnGameServerStop = EventBus.builder().throwSubscriberException(true).build(); OnGameServerTick = EventBus.builder().throwSubscriberException(true).logNoSubscriberMessages(false).build();
OnGameServerStop = EventBus.builder().throwSubscriberException(true).logNoSubscriberMessages(false).build();
this.setServerInitializer(new GameServerInitializer(this)); this.setServerInitializer(new GameServerInitializer(this));
this.address = address; this.address = address;
...@@ -171,13 +171,12 @@ public final class GameServer extends MihoyoKcpServer { ...@@ -171,13 +171,12 @@ public final class GameServer extends MihoyoKcpServer {
@Override @Override
public void onStartFinish() { public void onStartFinish() {
Grasscutter.getLogger().info("Game Server started on port " + address.getPort()); Grasscutter.getLogger().info("Game Server started on port " + address.getPort());
OnGameServerStartFinish.post(new GameServerStartFinishEvent());
} }
public void onServerShutdown() { public void onServerShutdown() {
OnGameServerStop.post(new GameServerStopEvent()); 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());
......
package emu.grasscutter.server.game;
public class GameServerStartFinishEvent {
// 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