diff --git a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java index 6d747797b..774447058 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java +++ b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java @@ -1,7 +1,5 @@ package emu.grasscutter.server.game; -import static emu.grasscutter.config.Configuration.GAME_INFO; - import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerDebugMode; import emu.grasscutter.net.packet.*; @@ -9,6 +7,8 @@ import emu.grasscutter.server.event.game.ReceivePacketEvent; import emu.grasscutter.server.game.GameSession.SessionState; import it.unimi.dsi.fastutil.ints.*; +import static emu.grasscutter.config.Configuration.GAME_INFO; + public final class GameServerPacketHandler { private final Int2ObjectMap handlers; @@ -76,13 +76,11 @@ public final class GameServerPacketHandler { } // Invoke event. - ReceivePacketEvent event = new ReceivePacketEvent(session, opcode, payload); - event.call(); - if (!event.isCanceled()) // If event is not canceled, continue. - handler.handle(session, header, event.getPacketData()); + var event = new ReceivePacketEvent(session, opcode, payload); + if (!event.call()) // If event is not canceled, continue. + handler.handle(session, header, event.getPacketData()); } catch (Exception ex) { - // TODO Remove this when no more needed - ex.printStackTrace(); + Grasscutter.getLogger().warn("Unable to handle packet.", ex); } return; // Packet successfully handled } diff --git a/src/main/java/emu/grasscutter/server/game/session/GameSessionManager.java b/src/main/java/emu/grasscutter/server/game/session/GameSessionManager.java index 29931e12a..9ac341d6d 100644 --- a/src/main/java/emu/grasscutter/server/game/session/GameSessionManager.java +++ b/src/main/java/emu/grasscutter/server/game/session/GameSessionManager.java @@ -14,7 +14,7 @@ public final class GameSessionManager implements KcpListener { @Getter private static final GameSessionManager instance = new GameSessionManager(); @Getter private static final ExecutorService executor - = Executors.newFixedThreadPool(4); + = Executors.newWorkStealingPool(); @Getter private static final Map sessions = new ConcurrentHashMap<>();