Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
8e6aa50c
Commit
8e6aa50c
authored
Jun 17, 2022
by
Melledy
Browse files
Move ban check to GetPlayerTokenReq
parent
a2de0e23
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java
View file @
8e6aa50c
...
@@ -21,7 +21,6 @@ public class HandlerGetPlayerTokenReq extends PacketHandler {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
();
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java
View file @
8e6aa50c
...
@@ -15,37 +15,40 @@ public class PacketGetPlayerTokenRsp extends BasePacket {
...
@@ -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
().
getBan
EndTime
()
)
.
setBlackUidEndTime
(
black
EndTime
)
.
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
());
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment