Move ban check to GetPlayerTokenReq

This commit is contained in:
Melledy 2022-06-17 18:58:32 -07:00
parent 50f0a38e21
commit 9daf89b953
2 changed files with 35 additions and 27 deletions

View File

@ -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();

View File

@ -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());
}
}