Skip to content

Commit

Permalink
Fix #21
Browse files Browse the repository at this point in the history
  • Loading branch information
mattboy9921 committed Jun 24, 2022
1 parent c4e01db commit 4e489cc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
74 changes: 37 additions & 37 deletions src/main/java/net/mattlabs/crewchat/messaging/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand All @@ -303,8 +303,8 @@ public Component partyListHeader() {
private String channelListActive = "You are currently active in: <channel_name>.";

public Component channelListActive(String name, TextColor textColor) {
return MiniMessage.miniMessage().deserialize("<gray>" + MessageUtil.sanitizeMessage(channelListActive),
TagResolver.resolver(Placeholder.parsed("channel_name", "<color:" + textColor.asHexString() + "><bold>" + name + "</bold></color:" + textColor.asHexString() + "><gray>")));
return MiniMessage.miniMessage().deserialize("<gray>" + channelListActive,
Placeholder.parsed("channel_name", "<color:" + textColor.asHexString() + "><bold>" + name + "</bold></color:" + textColor.asHexString() + "><gray>"));
}

// Channel List Subscribe Header
Expand All @@ -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();
}

Expand All @@ -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();
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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) + "<reset>"))))
statusSet,
TagResolver.resolver(Placeholder.parsed("status", MessageUtil.sanitizeMessageColor(status) + "<reset>"))))
.build();
}

Expand All @@ -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) + "<reset>"))))
statusIs,
TagResolver.resolver(Placeholder.parsed("status", MessageUtil.sanitizeMessageColor(status) + "<reset>"))))
.build();
}

Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -1013,7 +1013,7 @@ public Component broadcastMessage(String message) {
private String party = "party";

// Party Header
private transient Component partyHeader = MiniMessage.miniMessage().deserialize("<gray>[<dark_green>" + WordUtils.capitalize(MessageUtil.sanitizeMessage(party)) + "<gray>] ");
private transient Component partyHeader = MiniMessage.miniMessage().deserialize("<gray>[<dark_green>" + WordUtils.capitalize(party) + "<gray>] ");

// Party Exists
@Comment("\nAppears if a party already exists during creation.\n" +
Expand Down Expand Up @@ -1080,7 +1080,7 @@ public Component partyNoExist(String partyName) {
// Pick a Color Swatch Hover Text
private HoverEvent<Component> 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))
Expand Down Expand Up @@ -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", "<color:" + textColor.asHexString() + "><bold>" + partyName + "</bold></color:" + textColor.asHexString() + ">"))))
.build();
}
Expand All @@ -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", "<color:" + textColor.asHexString() + "><bold>" + partyName + "</bold></color:" + textColor.asHexString() + ">"))))
.build();
}
Expand All @@ -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();
}

Expand All @@ -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", "<hover:show_text:'<white>" + 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", "<hover:show_text:'<white>" + time + "\n" + senderStatus + "'>" + WordUtils.capitalize(you)),
Placeholder.parsed("recipient_prefix", recipientPrefix),
Placeholder.parsed("recipient_name", "<hover:show_text:'<white>" + time + "\n" + recipientStatus + "'>" + recipientName))))
.append(MessageUtil.parseMarkdown(MiniMessage.miniMessage().deserialize(message)))
.build();
Expand All @@ -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", "<hover:show_text:'<white>" + time + "\n" + senderStatus + "'>" + senderName),
Placeholder.parsed("recipient_prefix", MessageUtil.serialize(recipientPrefix)),
Placeholder.parsed("recipient_name", "<hover:show_text:'<white>" + time + "\n" + recipientStatus + "'>" + MessageUtil.sanitizeMessage(WordUtils.capitalize(you))))))
Placeholder.parsed("recipient_prefix", recipientPrefix),
Placeholder.parsed("recipient_name", "<hover:show_text:'<white>" + time + "\n" + recipientStatus + "'>" + WordUtils.capitalize(you)))))
.append(MessageUtil.parseMarkdown(MiniMessage.miniMessage().deserialize(
"<hover:show_text:'" + clickToReply + "'><click:suggest_command:/msg " + senderName + " >" + message)))
.build();
Expand Down Expand Up @@ -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()
Expand All @@ -1419,9 +1419,9 @@ public Component chatMessage(String prefix, String playerName, String time, Stri
// Message sent time
"<hover:show_text:'<white>" + time + "\n" +
// Message sender status
MessageUtil.sanitizeMessage(WordUtils.capitalize(this.status)) + ": " + MessageUtil.escapeSingleQuotes(status) + "<reset>\n" +
WordUtils.capitalize(this.status) + ": " + MessageUtil.sanitizeMessageColor(MessageUtil.escapeSingleQuotes(status)) + "<reset>\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 ? "<gray>[</gray><" + textColor.asHexString() + ">" + activeChannel + "</color:" + textColor.asHexString() + "><gray>]</gray> " : "") +
// Header
Expand All @@ -1442,19 +1442,19 @@ 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()
// Message header
.append(MiniMessage.miniMessage().deserialize(
// * Hover text
// Message sent time
"<hover:show_text:'<white>" + time + "\n" +
"<hover:show_text:'<white>" + time + "<newline>" +
// Message sender status
MessageUtil.sanitizeMessage(WordUtils.capitalize(this.status)) + ": " + MessageUtil.escapeSingleQuotes(status) + "\n" +
WordUtils.capitalize(this.status) + ": " + MessageUtil.escapeSingleQuotes(status) + "<newline>" +
// Message channel
MessageUtil.sanitizeMessage(WordUtils.capitalize(this.channel)) + ": " + "<" + textColor.asHexString() + ">" + activeChannel + "'>" +
WordUtils.capitalize(this.channel) + ": " + "<" + textColor.asHexString() + ">" + activeChannel + "'>" +
// Header
discordMessageHeader + "</hover>",
placeholders))
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/mattlabs/crewchat/util/ChatSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 4e489cc

Please sign in to comment.