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
48cd9f6b
Commit
48cd9f6b
authored
Aug 17, 2022
by
AnimeGitB
Browse files
Don't use UIDs as initial capacity for chat history
parent
fab7e4a4
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/chat/ChatSystem.java
View file @
48cd9f6b
...
...
@@ -51,8 +51,8 @@ public class ChatSystem implements ChatSystemHandler {
* Chat history handling
********************/
private
void
putInHistory
(
int
uid
,
int
partnerId
,
ChatInfo
info
)
{
this
.
history
.
computeIfAbsent
(
uid
,
HashMap
:
:
new
)
.
computeIfAbsent
(
partnerId
,
ArrayList
:
:
new
)
this
.
history
.
computeIfAbsent
(
uid
,
x
->
new
HashMap
<>()
)
.
computeIfAbsent
(
partnerId
,
x
->
new
ArrayList
<>()
)
.
add
(
info
);
}
...
...
@@ -61,14 +61,14 @@ public class ChatSystem implements ChatSystemHandler {
}
public
void
handlePullPrivateChatReq
(
Player
player
,
int
partnerId
)
{
var
chatHistory
=
this
.
history
.
computeIfAbsent
(
player
.
getUid
(),
HashMap
:
:
new
)
.
computeIfAbsent
(
partnerId
,
ArrayList
:
:
new
);
var
chatHistory
=
this
.
history
.
computeIfAbsent
(
player
.
getUid
(),
x
->
new
HashMap
<>()
)
.
computeIfAbsent
(
partnerId
,
x
->
new
ArrayList
<>()
);
player
.
sendPacket
(
new
PacketPullPrivateChatRsp
(
chatHistory
));
}
public
void
handlePullRecentChatReq
(
Player
player
)
{
// If this user has no chat history yet, create it by sending the server welcome messages.
if
(!
this
.
history
.
computeIfAbsent
(
player
.
getUid
(),
HashMap
:
:
new
).
containsKey
(
GameConstants
.
SERVER_CONSOLE_UID
))
{
if
(!
this
.
history
.
computeIfAbsent
(
player
.
getUid
(),
x
->
new
HashMap
<>()
).
containsKey
(
GameConstants
.
SERVER_CONSOLE_UID
))
{
this
.
sendServerWelcomeMessages
(
player
);
}
...
...
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