Commit 8e6aa50c authored by Melledy's avatar Melledy
Browse files

Move ban check to GetPlayerTokenReq

parent a2de0e23
......@@ -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
......@@ -79,6 +77,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();
......
......@@ -15,21 +15,6 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
this.setUseDispatchKey(true);
if (session.getPlayer().getAccount().isBanned()) {
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())
.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())
......@@ -47,5 +32,23 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
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(retcode)
.setMsg(msg)
.setBlackUidEndTime(blackEndTime)
.setRegPlatform(3)
.setCountryCode("US")
.setClientIpStr(session.getAddress().getAddress().getHostAddress())
.build();
this.setData(p.toByteArray());
}
}
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