mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 08:42:53 +08:00
Move ban check to GetPlayerTokenReq
This commit is contained in:
parent
a2de0e2376
commit
8e6aa50c3a
@ -21,7 +21,6 @@ public class HandlerGetPlayerTokenReq extends PacketHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
|
|
||||||
GetPlayerTokenReq req = GetPlayerTokenReq.parseFrom(payload);
|
GetPlayerTokenReq req = GetPlayerTokenReq.parseFrom(payload);
|
||||||
|
|
||||||
// Authenticate
|
// Authenticate
|
||||||
@ -33,7 +32,6 @@ public class HandlerGetPlayerTokenReq extends PacketHandler {
|
|||||||
// Set account
|
// Set account
|
||||||
session.setAccount(account);
|
session.setAccount(account);
|
||||||
|
|
||||||
|
|
||||||
// Check if player object exists in server
|
// Check if player object exists in server
|
||||||
// NOTE: CHECKING MUST SITUATED HERE (BEFORE getPlayerByUid)! because to save firstly ,to load secondly !!!
|
// NOTE: CHECKING MUST SITUATED HERE (BEFORE getPlayerByUid)! because to save firstly ,to load secondly !!!
|
||||||
// TODO - optimize
|
// TODO - optimize
|
||||||
@ -78,6 +76,13 @@ public class HandlerGetPlayerTokenReq extends PacketHandler {
|
|||||||
|
|
||||||
// Set player object for session
|
// Set player object for session
|
||||||
session.setPlayer(player);
|
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
|
// Load player from database
|
||||||
player.loadFromDatabase();
|
player.loadFromDatabase();
|
||||||
|
@ -15,37 +15,40 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
|
|||||||
|
|
||||||
this.setUseDispatchKey(true);
|
this.setUseDispatchKey(true);
|
||||||
|
|
||||||
if (session.getPlayer().getAccount().isBanned()) {
|
GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder()
|
||||||
|
.setUid(session.getPlayer().getUid())
|
||||||
GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder()
|
.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())
|
.setUid(session.getPlayer().getUid())
|
||||||
.setIsProficientPlayer(session.getPlayer().getAvatars().getAvatarCount() > 0)
|
.setIsProficientPlayer(session.getPlayer().getAvatars().getAvatarCount() > 0)
|
||||||
.setRetcode(21)
|
.setRetcode(retcode)
|
||||||
.setMsg("FORBID_CHEATING_PLUGINS")
|
.setMsg(msg)
|
||||||
.setBlackUidEndTime(session.getPlayer().getAccount().getBanEndTime())
|
.setBlackUidEndTime(blackEndTime)
|
||||||
.setRegPlatform(3)
|
.setRegPlatform(3)
|
||||||
.setCountryCode("US")
|
.setCountryCode("US")
|
||||||
.setClientIpStr(session.getAddress().getAddress().getHostAddress())
|
.setClientIpStr(session.getAddress().getAddress().getHostAddress())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.setData(p.toByteArray());
|
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user