Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat PM short channel name #99

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/java/org/polyfrost/hytils/config/HytilsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class LanguageData {
private String chatRestylerFriendPattern = "^((?:\u00a7r)?\u00a7\\w)(Friend >)";
private String chatRestylerOfficerPattern = "^((?:\u00a7r)?\u00a7\\w)(Officer >)";
private String chatRestylerStatusPattern = "^(?<type>(?:\u00a7aFriend|\u00a7a\u00a7aF|\u00a72Guild|\u00a72\u00a72G)) > (\u00a7r|\u00a7r\u00a7r){1,2}(?<player>\u00a7[\\da-f]\\w{1,16}) \u00a7r\u00a7e(?<status>(?:joined|left))\\.\u00a7r$";
private String chatRestylerPrivateMessageToPattern = "^((?:\u00a7r)?\u00a7\\w)(To)";
Zickles marked this conversation as resolved.
Show resolved Hide resolved
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(?:.*))$";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading