diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index 4715313..4d08c05 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -321,6 +321,13 @@ public class HytilsConfig extends Config { ) public static boolean shortChannelNames; + @Switch( + name = "Short Private Message Channel Names", + description = "Abbreviate private message channel names.\n§eExample: §dTo and §dFrom §e-> PM", + category = "Chat", subcategory = "Visual" + ) + public static boolean pmShortChannelNames; + @Switch( name = "Party Chat Swapper", description = "Automatically change to and out of a party channel when joining/leaving a party.", diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/DefaultChatRestyler.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/DefaultChatRestyler.java index 08f7438..c3536df 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/DefaultChatRestyler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/DefaultChatRestyler.java @@ -97,6 +97,18 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { } } + if (HytilsConfig.pmShortChannelNames) { + Matcher privateMessageToMatcher = language.chatRestylerPrivateMessageToPatternRegex.matcher(message); + Matcher privateMessageFromMatcher = language.chatRestylerPrivateMessageFromPatternRegex.matcher(message); + if (privateMessageToMatcher.find()) { + event.message = shortenChannelName(event.message, language.chatRestylerPrivateMessageToPatternRegex.pattern(), + "§d" + "PM >", true); + } else if (privateMessageFromMatcher.find()) { + event.message = shortenChannelName(event.message, language.chatRestylerPrivateMessageFromPatternRegex.pattern(), + "§5" + "PM <", true); + } + } + if (HytilsConfig.coloredStatuses) { Matcher statusMatcher = getLanguage().chatRestylerStatusPatternRegex.matcher(event.message.getFormattedText().trim()); if (statusMatcher.matches()) { diff --git a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java index c15501b..c3be347 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java +++ b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageData.java @@ -80,6 +80,8 @@ public class LanguageData { private String chatRestylerFriendPattern = "^((?:\u00a7r)?\u00a7\\w)(Friend >)"; private String chatRestylerOfficerPattern = "^((?:\u00a7r)?\u00a7\\w)(Officer >)"; private String chatRestylerStatusPattern = "^(?(?:\u00a7aFriend|\u00a7a\u00a7aF|\u00a72Guild|\u00a72\u00a72G)) > (\u00a7r|\u00a7r\u00a7r){1,2}(?\u00a7[\\da-f]\\w{1,16}) \u00a7r\u00a7e(?(?:joined|left))\\.\u00a7r$"; + private String chatRestylerPrivateMessageToPattern = "^((?:\u00a7r)?\u00a7\\w)(To)"; + private String chatRestylerPrivateMessageFromPattern = "^((?:\u00a7r)?\u00a7\\w)(From)"; private String autoChatSwapperPartyStatus = "^(?:You have been kicked from the party by (?:\\[.+] )?\\w{1,16}|(?:\\[.+] )?\\w{1,16} has disbanded the party!|You left the party.)$"; private String autoChatSwapperPartyStatus2 = "^(?:You have joined (?:\\[.+] )?(?:.*)|Party Members(?:\\[.+] )?\\w{1,100}|(?:\\[.+] )?\\w{1,100} joined the(?:.*) party(?:.*))$"; @@ -157,6 +159,8 @@ public class LanguageData { public Pattern chatRestylerFriendPatternRegex; public Pattern chatRestylerOfficerPatternRegex; public Pattern chatRestylerStatusPatternRegex; + public Pattern chatRestylerPrivateMessageToPatternRegex; + public Pattern chatRestylerPrivateMessageFromPatternRegex; public Pattern autoChatSwapperPartyStatusRegex; public Pattern autoChatSwapperPartyStatusRegex2; @@ -223,6 +227,8 @@ public void initialize() { chatRestylerFriendPatternRegex = Pattern.compile(chatRestylerFriendPattern); chatRestylerOfficerPatternRegex = Pattern.compile(chatRestylerOfficerPattern); chatRestylerStatusPatternRegex = Pattern.compile(chatRestylerStatusPattern); + chatRestylerPrivateMessageToPatternRegex = Pattern.compile(chatRestylerPrivateMessageToPattern); + chatRestylerPrivateMessageFromPatternRegex = Pattern.compile(chatRestylerPrivateMessageFromPattern); autoChatSwapperPartyStatusRegex = Pattern.compile(autoChatSwapperPartyStatus); autoChatSwapperPartyStatusRegex2 = Pattern.compile(autoChatSwapperPartyStatus2);