diff --git a/src/main/java/emu/grasscutter/game/managers/ChatManager.java b/src/main/java/emu/grasscutter/game/managers/ChatManager.java index 64729cb37..3856c0fd1 100644 --- a/src/main/java/emu/grasscutter/game/managers/ChatManager.java +++ b/src/main/java/emu/grasscutter/game/managers/ChatManager.java @@ -7,7 +7,12 @@ import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.packet.send.PacketPlayerChatNotify; import emu.grasscutter.server.packet.send.PacketPrivateChatNotify; +import java.util.Arrays; +import java.util.List; + public class ChatManager { + static final List PREFIXES = Arrays.asList('/', '!'); + private final GameServer server; public ChatManager(GameServer server) { @@ -18,14 +23,14 @@ public class ChatManager { return server; } - public void sendPrivChat(GenshinPlayer player, int targetUid, String message) { + public void sendPrivateMessage(GenshinPlayer player, int targetUid, String message) { // Sanity checks if (message == null || message.length() == 0) { return; } // Check if command - if (message.charAt(0) == '!') { + if (PREFIXES.contains(message.charAt(0))) { CommandMap.getInstance().invoke(player, message); return; } @@ -44,7 +49,7 @@ public class ChatManager { target.sendPacket(packet); } - public void sendPrivChat(GenshinPlayer player, int targetUid, int emote) { + public void sendPrivateMessage(GenshinPlayer player, int targetUid, int emote) { // Get target GenshinPlayer target = getServer().getPlayerById(targetUid); @@ -59,14 +64,14 @@ public class ChatManager { target.sendPacket(packet); } - public void sendTeamChat(GenshinPlayer player, int channel, String message) { + public void sendTeamMessage(GenshinPlayer player, int channel, String message) { // Sanity checks if (message == null || message.length() == 0) { return; } // Check if command - if (message.charAt(0) == '!') { + if (PREFIXES.contains(message.charAt(0))) { CommandMap.getInstance().invoke(player, message); return; } @@ -75,7 +80,7 @@ public class ChatManager { player.getWorld().broadcastPacket(new PacketPlayerChatNotify(player, channel, message)); } - public void sendTeamChat(GenshinPlayer player, int channel, int icon) { + public void sendTeamMessage(GenshinPlayer player, int channel, int icon) { // Create and send chat packet player.getWorld().broadcastPacket(new PacketPlayerChatNotify(player, channel, icon)); } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerChatReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerChatReq.java index 9a807e991..db0704ed8 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerChatReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerChatReq.java @@ -17,9 +17,9 @@ public class HandlerPlayerChatReq extends PacketHandler { ChatInfo.ContentCase content = req.getChatInfo().getContentCase(); if (content == ChatInfo.ContentCase.TEXT) { - session.getServer().getChatManager().sendTeamChat(session.getPlayer(), req.getChannelId(), req.getChatInfo().getText()); + session.getServer().getChatManager().sendTeamMessage(session.getPlayer(), req.getChannelId(), req.getChatInfo().getText()); } else if (content == ChatInfo.ContentCase.ICON) { - session.getServer().getChatManager().sendTeamChat(session.getPlayer(), req.getChannelId(), req.getChatInfo().getIcon()); + session.getServer().getChatManager().sendTeamMessage(session.getPlayer(), req.getChannelId(), req.getChatInfo().getIcon()); } session.send(new PacketPlayerChatRsp()); diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPrivateChatReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPrivateChatReq.java index 081c0883a..b576bbb20 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerPrivateChatReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerPrivateChatReq.java @@ -15,9 +15,9 @@ public class HandlerPrivateChatReq extends PacketHandler { PrivateChatReq.ContentCase content = req.getContentCase(); if (content == PrivateChatReq.ContentCase.TEXT) { - session.getServer().getChatManager().sendPrivChat(session.getPlayer(), req.getTargetUid(), req.getText()); + session.getServer().getChatManager().sendPrivateMessage(session.getPlayer(), req.getTargetUid(), req.getText()); } else if (content == PrivateChatReq.ContentCase.ICON) { - session.getServer().getChatManager().sendPrivChat(session.getPlayer(), req.getTargetUid(), req.getIcon()); + session.getServer().getChatManager().sendPrivateMessage(session.getPlayer(), req.getTargetUid(), req.getIcon()); } //session.send(new GenshinPacket(PacketOpcodes.PrivateChatRsp)); // Unused by server