diff --git a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java index d40b3d33d..14e98cbb6 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java +++ b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java @@ -1,19 +1,17 @@ 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.Opcodes; -import emu.grasscutter.net.packet.PacketHandler; -import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.packet.*; import emu.grasscutter.server.event.game.ReceivePacketEvent; import emu.grasscutter.server.game.GameSession.SessionState; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import java.util.Set; +import it.unimi.dsi.fastutil.ints.*; import org.reflections.Reflections; +import java.util.Set; + +import static emu.grasscutter.config.Configuration.GAME_INFO; + @SuppressWarnings("unchecked") public class GameServerPacketHandler { private final Int2ObjectMap handlers; diff --git a/src/main/java/emu/grasscutter/server/game/GameSession.java b/src/main/java/emu/grasscutter/server/game/GameSession.java index 0cff31cd1..700483ad6 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSession.java +++ b/src/main/java/emu/grasscutter/server/game/GameSession.java @@ -1,8 +1,5 @@ package emu.grasscutter.server.game; -import static emu.grasscutter.config.Configuration.*; -import static emu.grasscutter.utils.lang.Language.translate; - import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerDebugMode; import emu.grasscutter.game.Account; @@ -11,10 +8,14 @@ import emu.grasscutter.net.packet.*; import emu.grasscutter.server.event.game.SendPacketEvent; import emu.grasscutter.utils.*; import io.netty.buffer.*; +import lombok.*; + import java.io.File; import java.net.InetSocketAddress; import java.nio.file.Path; -import lombok.*; + +import static emu.grasscutter.config.Configuration.*; +import static emu.grasscutter.utils.lang.Language.translate; public class GameSession implements GameSessionManager.KcpChannel { private final GameServer server; diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerFireWorkReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerFireWorkReq.java deleted file mode 100644 index e18d9249a..000000000 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerFireWorkReq.java +++ /dev/null @@ -1,19 +0,0 @@ -package emu.grasscutter.server.packet.recv; - -import emu.grasscutter.net.packet.Opcodes; -import emu.grasscutter.net.packet.PacketHandler; -import emu.grasscutter.net.packet.PacketOpcodes; -import emu.grasscutter.net.proto.LaunchFireworksReqOuterClass.LaunchFireworksReq; -import emu.grasscutter.server.game.GameSession; -import emu.grasscutter.server.packet.send.PacketFireworkNotify; -import emu.grasscutter.server.packet.send.PacketFireworkRsp; - -@Opcodes(PacketOpcodes.FireworkReq) -public class HandlerFireWorkReq extends PacketHandler { - @Override - public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - var req = LaunchFireworksReq.parseFrom(payload); - session.send(new PacketFireworkNotify(req.getSchemeData())); - session.send(new PacketFireworkRsp()); - } -} diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerFireworkSetReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerFireworkSetReq.java deleted file mode 100644 index 79ff30311..000000000 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerFireworkSetReq.java +++ /dev/null @@ -1,17 +0,0 @@ -package emu.grasscutter.server.packet.recv; - -import emu.grasscutter.net.packet.*; -import emu.grasscutter.net.proto.ReformFireworksReqOuterClass.ReformFireworksReq; -import emu.grasscutter.server.game.GameSession; -import emu.grasscutter.server.packet.send.*; - -@Opcodes(PacketOpcodes.FireworkSetReq) -public class HandlerFireworkSetReq extends PacketHandler { - @Override - public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - var req = ReformFireworksReq.parseFrom(payload); - - session.send(new PacketFireworkSetNotify(req.getFireworksReformData())); - session.send(new PacketFireworkSetRsp()); - } -} diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java index b77f7cb03..031448597 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java @@ -1,25 +1,22 @@ package emu.grasscutter.server.packet.recv; -import static emu.grasscutter.config.Configuration.ACCOUNT; - import emu.grasscutter.Grasscutter; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.Player; -import emu.grasscutter.net.packet.Opcodes; -import emu.grasscutter.net.packet.PacketHandler; -import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.packet.*; import emu.grasscutter.net.proto.GetPlayerTokenReqOuterClass.GetPlayerTokenReq; import emu.grasscutter.server.event.game.PlayerCreationEvent; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession.SessionState; import emu.grasscutter.server.packet.send.PacketGetPlayerTokenRsp; -import emu.grasscutter.utils.Crypto; -import emu.grasscutter.utils.DispatchUtils; -import emu.grasscutter.utils.Utils; +import emu.grasscutter.utils.*; import emu.grasscutter.utils.helpers.ByteHelper; + +import javax.crypto.Cipher; import java.nio.ByteBuffer; import java.security.Signature; -import javax.crypto.Cipher; + +import static emu.grasscutter.config.Configuration.ACCOUNT; @Opcodes(PacketOpcodes.GetPlayerTokenReq) public class HandlerGetPlayerTokenReq extends PacketHandler { diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerLaunchFireworksReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerLaunchFireworksReq.java index 48d25e0ce..369fa4e24 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerLaunchFireworksReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerLaunchFireworksReq.java @@ -1,12 +1,9 @@ -// removed due to proto not existing - -/* package emu.grasscutter.server.packet.recv; import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketOpcodes; -import emu.grasscutter.net.proto.LaunchFireworksReqOuterClass; +import emu.grasscutter.net.proto.LaunchFireworksReqOuterClass.LaunchFireworksReq; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.packet.send.PacketFireworksLaunchDataNotify; import emu.grasscutter.server.packet.send.PacketLaunchFireworksRsp; @@ -15,13 +12,8 @@ import emu.grasscutter.server.packet.send.PacketLaunchFireworksRsp; public class HandlerLaunchFireworksReq extends PacketHandler { @Override public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - - var req - = LaunchFireworksReqOuterClass.LaunchFireworksReq.parseFrom(payload); - - + var req = LaunchFireworksReq.parseFrom(payload); session.send(new PacketFireworksLaunchDataNotify(req.getSchemeData())); session.send(new PacketLaunchFireworksRsp()); } } -*/ \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerReformFireworksReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerReformFireworksReq.java index 609187971..ac434a236 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerReformFireworksReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerReformFireworksReq.java @@ -1,24 +1,17 @@ -// removed due to proto not existing -/* package emu.grasscutter.server.packet.recv; -import emu.grasscutter.net.packet.Opcodes; -import emu.grasscutter.net.packet.PacketHandler; -import emu.grasscutter.net.packet.PacketOpcodes; -import emu.grasscutter.net.proto.ReformFireworksReqOuterClass; +import emu.grasscutter.net.packet.*; +import emu.grasscutter.net.proto.ReformFireworksReqOuterClass.ReformFireworksReq; import emu.grasscutter.server.game.GameSession; -import emu.grasscutter.server.packet.send.PacketFireworksReformDataNotify; -import emu.grasscutter.server.packet.send.PacketReformFireworksRsp; +import emu.grasscutter.server.packet.send.*; @Opcodes(PacketOpcodes.ReformFireworksReq) -public class HandlerReformFireworksReq extends PacketHandler { +public final class HandlerReformFireworksReq extends PacketHandler { @Override public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + var req = ReformFireworksReq.parseFrom(payload); - var req - = ReformFireworksReqOuterClass.ReformFireworksReq.parseFrom(payload); session.send(new PacketFireworksReformDataNotify(req.getFireworksReformData())); - session.send(new PacketReformFireworksRsp()); + session.send(new PacketFireworkSetRsp()); } } -*/ \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkNotify.java deleted file mode 100644 index d050e97af..000000000 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkNotify.java +++ /dev/null @@ -1,13 +0,0 @@ -package emu.grasscutter.server.packet.send; - -import emu.grasscutter.net.packet.*; -import emu.grasscutter.net.proto.FireworksLaunchDataNotifyOuterClass.FireworksLaunchDataNotify; -import emu.grasscutter.net.proto.FireworksLaunchSchemeDataOuterClass.FireworksLaunchSchemeData; - -public class PacketFireworkNotify extends BasePacket { - public PacketFireworkNotify(FireworksLaunchSchemeData data) { - super(PacketOpcodes.FireworkNotify); - - this.setData(FireworksLaunchDataNotify.newBuilder().addSchemeDataList(data)); - } -} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkRsp.java deleted file mode 100644 index 442614e05..000000000 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkRsp.java +++ /dev/null @@ -1,11 +0,0 @@ -package emu.grasscutter.server.packet.send; - -import emu.grasscutter.net.packet.BasePacket; -import emu.grasscutter.net.packet.PacketOpcodes; - -public class PacketFireworkRsp extends BasePacket { - - public PacketFireworkRsp() { - super(PacketOpcodes.FireworkRsp); - } -} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkSetNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkSetNotify.java deleted file mode 100644 index cc36c013e..000000000 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkSetNotify.java +++ /dev/null @@ -1,14 +0,0 @@ -package emu.grasscutter.server.packet.send; - -import emu.grasscutter.net.packet.*; -import emu.grasscutter.net.proto.FireworksReformDataNotifyOuterClass.FireworksReformDataNotify; -import emu.grasscutter.net.proto.FireworksReformDataOuterClass.FireworksReformData; - -public class PacketFireworkSetNotify extends BasePacket { - - public PacketFireworkSetNotify(FireworksReformData data) { - super(PacketOpcodes.FireworkSetNotify); - - this.setData(FireworksReformDataNotify.newBuilder().addFireworksReformDataList(data)); - } -} diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkSetRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkSetRsp.java index ae11c96af..c05992984 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkSetRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketFireworkSetRsp.java @@ -6,7 +6,7 @@ import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode; public class PacketFireworkSetRsp extends BasePacket { public PacketFireworkSetRsp() { - super(PacketOpcodes.FireworkSetRsp); + super(PacketOpcodes.ReformFireworksRsp); this.setData(ReformFireworksRsp.newBuilder().setRetcode(Retcode.RET_SUCC.getNumber())); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworksLaunchDataNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketFireworksLaunchDataNotify.java index 4884e0009..6a40a7d65 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworksLaunchDataNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketFireworksLaunchDataNotify.java @@ -1,25 +1,13 @@ -// removed due to proto not existing - -/* package emu.grasscutter.server.packet.send; -import emu.grasscutter.net.packet.BasePacket; -import emu.grasscutter.net.packet.PacketOpcodes; -import emu.grasscutter.net.proto.FireworksLaunchDataNotifyOuterClass; -import emu.grasscutter.net.proto.FireworksLaunchSchemeDataOuterClass; +import emu.grasscutter.net.packet.*; +import emu.grasscutter.net.proto.FireworksLaunchDataNotifyOuterClass.FireworksLaunchDataNotify; +import emu.grasscutter.net.proto.FireworksLaunchSchemeDataOuterClass.FireworksLaunchSchemeData; public class PacketFireworksLaunchDataNotify extends BasePacket { - - public PacketFireworksLaunchDataNotify(FireworksLaunchSchemeDataOuterClass.FireworksLaunchSchemeData notify) { + public PacketFireworksLaunchDataNotify(FireworksLaunchSchemeData data) { super(PacketOpcodes.FireworksLaunchDataNotify); - var proto - = FireworksLaunchDataNotifyOuterClass.FireworksLaunchDataNotify.newBuilder(); - - proto.setLastUseSchemeId(1).addSchemeDataList(notify); - - setData(proto.build()); + this.setData(FireworksLaunchDataNotify.newBuilder().addSchemeDataList(data)); } - } -*/ \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworksReformDataNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketFireworksReformDataNotify.java index 15e5b6b5a..05e311456 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketFireworksReformDataNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketFireworksReformDataNotify.java @@ -1,25 +1,14 @@ -// removed due to proto not existing - -/* package emu.grasscutter.server.packet.send; -import emu.grasscutter.net.packet.BasePacket; -import emu.grasscutter.net.packet.PacketOpcodes; -import emu.grasscutter.net.proto.FireworksReformDataNotifyOuterClass; -import emu.grasscutter.net.proto.FireworksReformDataOuterClass; +import emu.grasscutter.net.packet.*; +import emu.grasscutter.net.proto.FireworksReformDataNotifyOuterClass.FireworksReformDataNotify; +import emu.grasscutter.net.proto.FireworksReformDataOuterClass.FireworksReformData; public class PacketFireworksReformDataNotify extends BasePacket { - public PacketFireworksReformDataNotify(FireworksReformDataOuterClass.FireworksReformData fireworksReformData) { + public PacketFireworksReformDataNotify(FireworksReformData data) { super(PacketOpcodes.FireworksReformDataNotify); - var proto - = FireworksReformDataNotifyOuterClass.FireworksReformDataNotify.newBuilder(); - - proto.addFireworksReformDataList(fireworksReformData); - - setData(proto.build()); + this.setData(FireworksReformDataNotify.newBuilder().addFireworksReformDataList(data)); } - } -*/ \ No newline at end of file