From 4e489cc49da1c8f8f7589afef09b41a61779617b Mon Sep 17 00:00:00 2001 From: mattboy9921 Date: Fri, 24 Jun 2022 16:32:15 -0400 Subject: [PATCH] Fix #21 --- .../mattlabs/crewchat/messaging/Messages.java | 74 +++++++++---------- .../mattlabs/crewchat/util/ChatSender.java | 2 +- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/main/java/net/mattlabs/crewchat/messaging/Messages.java b/src/main/java/net/mattlabs/crewchat/messaging/Messages.java index af1149d..69d15db 100644 --- a/src/main/java/net/mattlabs/crewchat/messaging/Messages.java +++ b/src/main/java/net/mattlabs/crewchat/messaging/Messages.java @@ -84,7 +84,7 @@ public Component chatBaseCommand() { return Component.text() .append(chatHeader) .append(MiniMessage.miniMessage().deserialize(welcomeToChat)) - .append(Component.text(" [" + MessageUtil.sanitizeMessage(WordUtils.capitalize(help)) + "]", BLUE, BOLD) + .append(Component.text(" [" + WordUtils.capitalize(help) + "]", BLUE, BOLD) .hoverEvent(HoverEvent.showText(Component.text() .append(MiniMessage.miniMessage().deserialize(clickForHelp)))) .clickEvent(ClickEvent.runCommand("/chat help"))) @@ -278,11 +278,11 @@ public Component channelListHeader() { return Component.text() .append(Component.text("------------------------", GRAY)) .append(Component.text("[", DARK_GRAY)) - .append(Component.text(MessageUtil.sanitizeMessage(WordUtils.capitalize(chat)), DARK_GREEN)) + .append(Component.text(WordUtils.capitalize(chat), DARK_GREEN)) .append(Component.text("]", DARK_GRAY)) .append(Component.text("------------------------", GRAY)) .append(Component.text("\n")) - .append(Component.text(MessageUtil.sanitizeMessage(channelListHeader), GRAY)) + .append(Component.text(channelListHeader, GRAY)) .build(); } @@ -293,7 +293,7 @@ public Component channelListHeader() { public Component partyListHeader() { return Component.text() - .append(Component.text(MessageUtil.sanitizeMessage(partyListHeader), GRAY)) + .append(Component.text(partyListHeader, GRAY)) .build(); } @@ -303,8 +303,8 @@ public Component partyListHeader() { private String channelListActive = "You are currently active in: ."; public Component channelListActive(String name, TextColor textColor) { - return MiniMessage.miniMessage().deserialize("" + MessageUtil.sanitizeMessage(channelListActive), - TagResolver.resolver(Placeholder.parsed("channel_name", "" + name + ""))); + return MiniMessage.miniMessage().deserialize("" + channelListActive, + Placeholder.parsed("channel_name", "" + name + "")); } // Channel List Subscribe Header @@ -314,7 +314,7 @@ public Component channelListActive(String name, TextColor textColor) { public Component channelListSubscribedHeader() { return Component.text() - .append(Component.text(MessageUtil.sanitizeMessage(channelListSubscribedHeader), GRAY)) + .append(Component.text(channelListSubscribedHeader, GRAY)) .build(); } @@ -325,7 +325,7 @@ public Component channelListSubscribedHeader() { public Component partyListJoinedHeader() { return Component.text() - .append(Component.text(MessageUtil.sanitizeMessage(partyListJoinedHeader), GRAY)) + .append(Component.text(partyListJoinedHeader, GRAY)) .build(); } @@ -336,7 +336,7 @@ public Component partyListJoinedHeader() { public Component mutedListHeader() { return Component.text() - .append(Component.text(MessageUtil.sanitizeMessage(mutedListHeader), GRAY)) + .append(Component.text(mutedListHeader, GRAY)) .build(); } @@ -450,7 +450,7 @@ public Component playerAlreadyMuted(String playerPrefix, String playerName) { return Component.text() .append(chatHeader) .append(MiniMessage.miniMessage().deserialize(playerAlreadyMuted, - TagResolver.resolver(Placeholder.parsed("player_prefix", MessageUtil.serialize(playerPrefix)), + TagResolver.resolver(Placeholder.parsed("player_prefix", playerPrefix), Placeholder.parsed("player_name", playerName)))) .build(); } @@ -464,7 +464,7 @@ public Component playerAlreadyUnmuted(String playerPrefix, String playerName) { return Component.text() .append(chatHeader) .append(MiniMessage.miniMessage().deserialize(playerAlreadyUnmuted, - TagResolver.resolver(Placeholder.parsed("player_prefix", MessageUtil.serialize(playerPrefix)), + TagResolver.resolver(Placeholder.parsed("player_prefix", playerPrefix), Placeholder.parsed("player_name", playerName)))) .build(); } @@ -478,7 +478,7 @@ public Component playerMuted(String playerPrefix, String player) { return Component.text() .append(chatHeader) .append(MiniMessage.miniMessage().deserialize(playerMuted, - TagResolver.resolver(Placeholder.parsed("player_prefix", MessageUtil.serialize(playerPrefix)), + TagResolver.resolver(Placeholder.parsed("player_prefix", playerPrefix), Placeholder.parsed("player_name", player)))) .build(); } @@ -492,7 +492,7 @@ public Component playerUnmuted(String playerPrefix, String player) { return Component.text() .append(chatHeader) .append(MiniMessage.miniMessage().deserialize(playerUnmuted, - TagResolver.resolver(Placeholder.parsed("player_prefix", MessageUtil.serialize(playerPrefix)), + TagResolver.resolver(Placeholder.parsed("player_prefix", playerPrefix), Placeholder.parsed("player_name", player)))) .build(); } @@ -509,8 +509,8 @@ public Component statusSet(String status) throws ParsingException { return Component.text() .append(chatHeader) .append(MiniMessage.miniMessage().deserialize( - MessageUtil.sanitizeMessageColor(statusSet), - TagResolver.resolver(Placeholder.parsed("status", MessageUtil.serialize(status) + "")))) + statusSet, + TagResolver.resolver(Placeholder.parsed("status", MessageUtil.sanitizeMessageColor(status) + "")))) .build(); } @@ -524,8 +524,8 @@ public Component statusIs(String status) throws ParsingException { return Component.text() .append(chatHeader) .append(MiniMessage.miniMessage().deserialize( - MessageUtil.sanitizeMessageColor(statusIs), - TagResolver.resolver(Placeholder.parsed("status", MessageUtil.serialize(status) + "")))) + statusIs, + TagResolver.resolver(Placeholder.parsed("status", MessageUtil.sanitizeMessageColor(status) + "")))) .build(); } @@ -733,7 +733,7 @@ public Component crewChatChannelListHeader() { .append(Component.text("CrewChat", DARK_GREEN)) .append(Component.text("]", DARK_GRAY)) .append(Component.text("----------------------", GRAY)) - .append(Component.text(MessageUtil.sanitizeMessage(channelListHeader), GRAY)) + .append(Component.text(channelListHeader, GRAY)) .build(); } @@ -1013,7 +1013,7 @@ public Component broadcastMessage(String message) { private String party = "party"; // Party Header - private transient Component partyHeader = MiniMessage.miniMessage().deserialize("[" + WordUtils.capitalize(MessageUtil.sanitizeMessage(party)) + "] "); + private transient Component partyHeader = MiniMessage.miniMessage().deserialize("[" + WordUtils.capitalize(party) + "] "); // Party Exists @Comment("\nAppears if a party already exists during creation.\n" + @@ -1080,7 +1080,7 @@ public Component partyNoExist(String partyName) { // Pick a Color Swatch Hover Text private HoverEvent pickAColorHover(String partyName, TextColor textColor) { return HoverEvent.showText(Component.text() - .append(Component.text(WordUtils.capitalize(MessageUtil.sanitizeMessage(preview)) + ": ", WHITE)) + .append(Component.text(WordUtils.capitalize(preview) + ": ", WHITE)) .append(Component.text(partyName, textColor, BOLD)) .append(Component.text("\n")) .append(MiniMessage.miniMessage().deserialize(clickToPick)) @@ -1279,7 +1279,7 @@ public Component playerJoinedParty(String prefix, String playerName, String part return Component.text() .append(partyHeader) .append(MiniMessage.miniMessage().deserialize(playerJoinedParty, - TagResolver.resolver(Placeholder.parsed("player_name", MessageUtil.serialize(prefix) + playerName), + TagResolver.resolver(Placeholder.parsed("player_name", prefix + playerName), Placeholder.parsed("party_name", "" + partyName + "")))) .build(); } @@ -1293,7 +1293,7 @@ public Component playerLeftParty(String prefix, String playerName, String partyN return Component.text() .append(partyHeader) .append(MiniMessage.miniMessage().deserialize(playerLeftParty, - TagResolver.resolver(Placeholder.parsed("player_name", MessageUtil.serialize(prefix) + playerName), + TagResolver.resolver(Placeholder.parsed("player_name", prefix + playerName), Placeholder.parsed("party_name", "" + partyName + "")))) .build(); } @@ -1313,7 +1313,7 @@ public Component partyPlayerListHeader(String partyName, TextColor textColor) { public Component partyPlayerListEntry(String prefix, String playerName) { return Component.text() .append(hyphenHeader) - .append(MiniMessage.miniMessage().deserialize(MessageUtil.serialize(prefix) + playerName)) + .append(MiniMessage.miniMessage().deserialize(prefix + playerName)) .build(); } @@ -1333,9 +1333,9 @@ public Component privateMessageSend(String senderPrefix, String recipientPrefix, // &7[%senderPrefix%me &7-> %recipientPrefix%%recipientName%&7] &r%message% return Component.text() .append(MiniMessage.miniMessage().deserialize(privateMessageHeader, - TagResolver.resolver(Placeholder.parsed("sender_prefix", MessageUtil.serialize(senderPrefix)), - Placeholder.parsed("sender_name", "" + time + "\n" + senderStatus + "'>" + MessageUtil.sanitizeMessage(WordUtils.capitalize(you))), - Placeholder.parsed("recipient_prefix", MessageUtil.serialize(recipientPrefix)), + TagResolver.resolver(Placeholder.parsed("sender_prefix", senderPrefix), + Placeholder.parsed("sender_name", "" + time + "\n" + senderStatus + "'>" + WordUtils.capitalize(you)), + Placeholder.parsed("recipient_prefix", recipientPrefix), Placeholder.parsed("recipient_name", "" + time + "\n" + recipientStatus + "'>" + recipientName)))) .append(MessageUtil.parseMarkdown(MiniMessage.miniMessage().deserialize(message))) .build(); @@ -1350,10 +1350,10 @@ public Component privateMessageReceive(String senderPrefix, String recipientPref // &7[%senderPrefix%%senderName% &7-> %recipientPrefix%Me&7] &r%message% return Component.text() .append(MiniMessage.miniMessage().deserialize(privateMessageHeader, - TagResolver.resolver(Placeholder.parsed("sender_prefix", MessageUtil.serialize(senderPrefix)), + TagResolver.resolver(Placeholder.parsed("sender_prefix", senderPrefix), Placeholder.parsed("sender_name", "" + time + "\n" + senderStatus + "'>" + senderName), - Placeholder.parsed("recipient_prefix", MessageUtil.serialize(recipientPrefix)), - Placeholder.parsed("recipient_name", "" + time + "\n" + recipientStatus + "'>" + MessageUtil.sanitizeMessage(WordUtils.capitalize(you)))))) + Placeholder.parsed("recipient_prefix", recipientPrefix), + Placeholder.parsed("recipient_name", "" + time + "\n" + recipientStatus + "'>" + WordUtils.capitalize(you))))) .append(MessageUtil.parseMarkdown(MiniMessage.miniMessage().deserialize( "" + message))) .build(); @@ -1407,7 +1407,7 @@ public Component chatMessage(String prefix, String playerName, String time, Stri // %prefix%%playerName%: %message% TagResolver placeholders = TagResolver.resolver(Placeholder.parsed( - "player_prefix", MessageUtil.serialize(prefix)), + "player_prefix", prefix), Placeholder.parsed("player_name", playerName)); return Component.text() @@ -1419,9 +1419,9 @@ public Component chatMessage(String prefix, String playerName, String time, Stri // Message sent time "" + time + "\n" + // Message sender status - MessageUtil.sanitizeMessage(WordUtils.capitalize(this.status)) + ": " + MessageUtil.escapeSingleQuotes(status) + "\n" + + WordUtils.capitalize(this.status) + ": " + MessageUtil.sanitizeMessageColor(MessageUtil.escapeSingleQuotes(status)) + "\n" + // Message sender channel or party - (isParty ? WordUtils.capitalize(MessageUtil.sanitizeMessage(party)) : MessageUtil.sanitizeMessage(WordUtils.capitalize(this.channel))) + ": " + "<" + textColor.asHexString() + ">" + activeChannel + "'>" + + (isParty ? WordUtils.capitalize(party) : WordUtils.capitalize(this.channel)) + ": " + "<" + textColor.asHexString() + ">" + activeChannel + "'>" + // Channel shown in prefix (showChannelName ? "[<" + textColor.asHexString() + ">" + activeChannel + "] " : "") + // Header @@ -1442,7 +1442,7 @@ public Component discordMessage(String discordHeader, String prefix, String play TagResolver placeholders = TagResolver.resolver( Placeholder.parsed("discord", discordHeader), - Placeholder.parsed("player_prefix", MessageUtil.serialize(prefix)), + Placeholder.parsed("player_prefix", prefix), Placeholder.parsed("player_name", playerName)); return Component.text() @@ -1450,11 +1450,11 @@ public Component discordMessage(String discordHeader, String prefix, String play .append(MiniMessage.miniMessage().deserialize( // * Hover text // Message sent time - "" + time + "\n" + + "" + time + "" + // Message sender status - MessageUtil.sanitizeMessage(WordUtils.capitalize(this.status)) + ": " + MessageUtil.escapeSingleQuotes(status) + "\n" + + WordUtils.capitalize(this.status) + ": " + MessageUtil.escapeSingleQuotes(status) + "" + // Message channel - MessageUtil.sanitizeMessage(WordUtils.capitalize(this.channel)) + ": " + "<" + textColor.asHexString() + ">" + activeChannel + "'>" + + WordUtils.capitalize(this.channel) + ": " + "<" + textColor.asHexString() + ">" + activeChannel + "'>" + // Header discordMessageHeader + "", placeholders)) @@ -1493,7 +1493,7 @@ public Component discordMessage(String discordHeader, String prefix, String play // [Chat] private transient Component chatHeader = Component.text() .append(Component.text("[", GRAY)) - .append(Component.text(MessageUtil.sanitizeMessage(WordUtils.capitalize(chat)), DARK_GREEN)) + .append(Component.text(WordUtils.capitalize(chat), DARK_GREEN)) .append(Component.text("] ", GRAY)) .build(); diff --git a/src/main/java/net/mattlabs/crewchat/util/ChatSender.java b/src/main/java/net/mattlabs/crewchat/util/ChatSender.java index 16822e2..a71f92b 100644 --- a/src/main/java/net/mattlabs/crewchat/util/ChatSender.java +++ b/src/main/java/net/mattlabs/crewchat/util/ChatSender.java @@ -62,7 +62,7 @@ public void sendChatMessage(Player player, String intendedChannel, String messag // Gather relavent info this.player = player; if (playerManager.isDeafened(player)) platform.player(player).sendMessage(crewChat.getMessages().playerIsDeafened()); - prefix = chat.getPlayerPrefix(player); + prefix = MessageUtil.serialize(chat.getPlayerPrefix(player)); name = player.getName(); SimpleDateFormat format = new SimpleDateFormat("EEE, MMM d, HH:mm:ss"); time = format.format(new Date());