mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 13:01:03 +00:00
Don't use UIDs as initial capacity for chat history
This commit is contained in:
parent
fab7e4a461
commit
48cd9f6be2
@ -51,8 +51,8 @@ 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) {
|
||||||
this.history.computeIfAbsent(uid, HashMap::new)
|
this.history.computeIfAbsent(uid, x -> new HashMap<>())
|
||||||
.computeIfAbsent(partnerId, ArrayList::new)
|
.computeIfAbsent(partnerId, x -> new ArrayList<>())
|
||||||
.add(info);
|
.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,14 +61,14 @@ public class ChatSystem implements ChatSystemHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handlePullPrivateChatReq(Player player, int partnerId) {
|
public void handlePullPrivateChatReq(Player player, int partnerId) {
|
||||||
var chatHistory = this.history.computeIfAbsent(player.getUid(), HashMap::new)
|
var chatHistory = this.history.computeIfAbsent(player.getUid(), x -> new HashMap<>())
|
||||||
.computeIfAbsent(partnerId, ArrayList::new);
|
.computeIfAbsent(partnerId, x -> new ArrayList<>());
|
||||||
player.sendPacket(new PacketPullPrivateChatRsp(chatHistory));
|
player.sendPacket(new PacketPullPrivateChatRsp(chatHistory));
|
||||||
}
|
}
|
||||||
|
|
||||||
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.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);
|
this.sendServerWelcomeMessages(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user