Skip to content

Commit ceae307

Browse files
committed
Re-add support for ignoring captured text style in custom messages
1 parent cd4fbcd commit ceae307

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

common/src/main/java/dev/terminalmc/chatnotify/util/MessageUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,13 @@ private static Component convertMsg(String msgString, @Nullable Matcher matcher,
367367

368368
// Substitute capturing groups
369369
if (matcher != null && matcher.find(0)) {
370+
// Capturing groups preceded by a $ (now §) sign should not retain
371+
// their original style, so we substitute them in first
372+
for (int i = 0; i <= matcher.groupCount(); i++) {
373+
String replacement = matcher.group(i) == null ? "" : matcher.group(i);
374+
msgString = msgString.replaceAll(\\(" + i + "\\)", replacement);
375+
}
376+
370377
// Convert message into a format suitable for recursive processing
371378
msg = FormatUtil.convertToStyledLiteral(msg.copy());
372379

common/src/main/resources/assets/chatnotify/lang/en_us.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"option.chatnotify.notif.misc.msg.tooltip.blank_hide": "Leave blank to hide the original message.",
116116
"option.chatnotify.notif.misc.msg.tooltip.blank_original": "Leave blank to display the original message.",
117117
"option.chatnotify.notif.misc.msg.tooltip.format_codes": "Use $4, $n etc. (format codes) to customize message style.",
118-
"option.chatnotify.notif.misc.msg.tooltip.regex_groups": "Use (1), (2) etc. to access capturing groups from a regex trigger.",
118+
"option.chatnotify.notif.misc.msg.tooltip.regex_groups": "Use (1), (2) etc. to access capturing groups from a regex trigger. Use $(1) to ignore the style of the captured text.",
119119
"option.chatnotify.notif.misc.reset": "Broken Everything?",
120120
"option.chatnotify.notif.misc.reset.button": "Reset Configuration",
121121
"option.chatnotify.notif.misc.reset.confirm": "Are you sure you want to delete all notifications and reset all settings?",

0 commit comments

Comments
 (0)