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 6546b6f1b..464d7a277 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java @@ -21,7 +21,6 @@ public class HandlerGetPlayerTokenReq extends PacketHandler { @Override public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { - GetPlayerTokenReq req = GetPlayerTokenReq.parseFrom(payload); // Authenticate @@ -33,7 +32,6 @@ public class HandlerGetPlayerTokenReq extends PacketHandler { // Set account session.setAccount(account); - // Check if player object exists in server // NOTE: CHECKING MUST SITUATED HERE (BEFORE getPlayerByUid)! because to save firstly ,to load secondly !!! // TODO - optimize @@ -78,6 +76,13 @@ public class HandlerGetPlayerTokenReq extends PacketHandler { // Set player object for session session.setPlayer(player); + + // Checks if the player is banned + if (session.getAccount().isBanned()) { + session.send(new PacketGetPlayerTokenRsp(session, 21, "FORBID_CHEATING_PLUGINS", session.getAccount().getBanEndTime())); + session.close(); + return; + } // Load player from database player.loadFromDatabase(); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java index 1b851d4cd..1377920e5 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java @@ -15,37 +15,40 @@ public class PacketGetPlayerTokenRsp extends BasePacket { this.setUseDispatchKey(true); - if (session.getPlayer().getAccount().isBanned()) { - - GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder() + GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder() + .setUid(session.getPlayer().getUid()) + .setToken(session.getAccount().getToken()) + .setAccountType(1) + .setIsProficientPlayer(session.getPlayer().getAvatars().getAvatarCount() > 0) // Not sure where this goes + .setSecretKeySeed(Crypto.ENCRYPT_SEED) + .setSecurityCmdBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER)) + .setPlatformType(3) + .setChannelId(1) + .setCountryCode("US") + .setClientVersionRandomKey("c25-314dd05b0b5f") + .setRegPlatform(3) + .setClientIpStr(session.getAddress().getAddress().getHostAddress()) + .build(); + + this.setData(p.toByteArray()); + } + + public PacketGetPlayerTokenRsp(GameSession session, int retcode, String msg, int blackEndTime) { + super(PacketOpcodes.GetPlayerTokenRsp, true); + + this.setUseDispatchKey(true); + + GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder() .setUid(session.getPlayer().getUid()) .setIsProficientPlayer(session.getPlayer().getAvatars().getAvatarCount() > 0) - .setRetcode(21) - .setMsg("FORBID_CHEATING_PLUGINS") - .setBlackUidEndTime(session.getPlayer().getAccount().getBanEndTime()) + .setRetcode(retcode) + .setMsg(msg) + .setBlackUidEndTime(blackEndTime) .setRegPlatform(3) .setCountryCode("US") .setClientIpStr(session.getAddress().getAddress().getHostAddress()) .build(); - this.setData(p.toByteArray()); - } else { - GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder() - .setUid(session.getPlayer().getUid()) - .setToken(session.getAccount().getToken()) - .setAccountType(1) - .setIsProficientPlayer(session.getPlayer().getAvatars().getAvatarCount() > 0) // Not sure where this goes - .setSecretKeySeed(Crypto.ENCRYPT_SEED) - .setSecurityCmdBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER)) - .setPlatformType(3) - .setChannelId(1) - .setCountryCode("US") - .setClientVersionRandomKey("c25-314dd05b0b5f") - .setRegPlatform(3) - .setClientIpStr(session.getAddress().getAddress().getHostAddress()) - .build(); - - this.setData(p.toByteArray()); - } + this.setData(p.toByteArray()); } }