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
fab7e4a4
Commit
fab7e4a4
authored
Aug 17, 2022
by
AnimeGitB
Browse files
ChatSystem nitpick
parent
dc153572
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/chat/ChatSystem.java
View file @
fab7e4a4
...
@@ -51,34 +51,24 @@ public class ChatSystem implements ChatSystemHandler {
...
@@ -51,34 +51,24 @@ public class ChatSystem implements ChatSystemHandler {
* Chat history handling
* Chat history handling
********************/
********************/
private
void
putInHistory
(
int
uid
,
int
partnerId
,
ChatInfo
info
)
{
private
void
putInHistory
(
int
uid
,
int
partnerId
,
ChatInfo
info
)
{
if
(!
this
.
history
.
containsKey
(
uid
))
{
this
.
history
.
computeIfAbsent
(
uid
,
HashMap:
:
new
)
this
.
history
.
put
(
uid
,
new
HashMap
<>());
.
computeIfAbsent
(
partnerId
,
ArrayList:
:
new
)
}
.
add
(
info
);
if
(!
this
.
history
.
get
(
uid
).
containsKey
(
partnerId
))
{
this
.
history
.
get
(
uid
).
put
(
partnerId
,
new
ArrayList
<>());
}
this
.
history
.
get
(
uid
).
get
(
partnerId
).
add
(
info
);
}
}
public
void
clearHistoryOnLogout
(
Player
player
)
{
public
void
clearHistoryOnLogout
(
Player
player
)
{
if
(
this
.
history
.
containsKey
(
player
.
getUid
()))
{
this
.
history
.
remove
(
player
.
getUid
());
this
.
history
.
remove
(
player
.
getUid
());
}
}
}
public
void
handlePullPrivateChatReq
(
Player
player
,
int
partnerId
)
{
public
void
handlePullPrivateChatReq
(
Player
player
,
int
partnerId
)
{
if
(
this
.
history
.
getOrDefault
(
player
.
getUid
(),
Map
.
of
()).
containsKey
(
partnerId
))
{
var
chatHistory
=
this
.
history
.
computeIfAbsent
(
player
.
getUid
(),
HashMap:
:
new
)
player
.
sendPacket
(
new
PacketPullPrivateChatRsp
(
this
.
history
.
get
(
player
.
getUid
()).
get
(
partnerId
)));
.
computeIfAbsent
(
partnerId
,
ArrayList:
:
new
);
}
player
.
sendPacket
(
new
PacketPullPrivateChatRsp
(
chatHistory
));
else
{
player
.
sendPacket
(
new
PacketPullPrivateChatRsp
(
List
.
of
()));
}
}
}
public
void
handlePullRecentChatReq
(
Player
player
)
{
public
void
handlePullRecentChatReq
(
Player
player
)
{
// If this user has no chat history yet, create it by sending the server welcome messages.
// If this user has no chat history yet, create it by sending the server welcome messages.
if
(!
this
.
history
.
getOrDefaul
t
(
player
.
getUid
(),
Map
.
of
()
).
containsKey
(
GameConstants
.
SERVER_CONSOLE_UID
))
{
if
(!
this
.
history
.
computeIfAbsen
t
(
player
.
getUid
(),
HashMap:
:
new
).
containsKey
(
GameConstants
.
SERVER_CONSOLE_UID
))
{
this
.
sendServerWelcomeMessages
(
player
);
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