Skip to content

Commit 4da2b5c

Browse files
committed
BetterChat timestamp seconds
closes #3946
1 parent 5ee8f08 commit 4da2b5c

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

  • src/main/java/meteordevelopment/meteorclient/systems/modules/misc

src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ public class BetterChat extends Module {
7474
.build()
7575
);
7676

77+
private final Setting<Boolean> showSeconds = sgGeneral.add(new BoolSetting.Builder()
78+
.name("show-seconds")
79+
.description("Shows seconds in the chat message timestamps")
80+
.defaultValue(false)
81+
.visible(timestamps::get)
82+
.onChanged(o -> updateDateFormat())
83+
.build()
84+
);
85+
7786
private final Setting<Boolean> playerHeads = sgGeneral.add(new BoolSetting.Builder()
7887
.name("player-heads")
7988
.description("Displays player heads next to their messages.")
@@ -229,11 +238,10 @@ public class BetterChat extends Module {
229238

230239
private static final Pattern antiSpamRegex = Pattern.compile(" \\(([0-9]{1,9})\\)$");
231240
private static final Pattern antiClearRegex = Pattern.compile("\\n(\\n|\\s)+\\n");
232-
private static final Pattern timestampRegex = Pattern.compile("^(<[0-9]{2}:[0-9]{2}>\\s)");
241+
private static final Pattern timestampRegex = Pattern.compile("^(<[0-9]{2}:[0-9]{2}(?::[0-9]{2})?> )");
233242
private static final Pattern usernameRegex = Pattern.compile("^(?:<[0-9]{2}:[0-9]{2}>\\s)?<(.*?)>.*");
234243

235244
private final Char2CharMap SMALL_CAPS = new Char2CharOpenHashMap();
236-
private final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
237245
public final IntList lines = new IntArrayList();
238246

239247
public BetterChat() {
@@ -335,7 +343,7 @@ private Text appendAntiSpam(Text text) {
335343

336344
Matcher timestampMatcher = timestampRegex.matcher(stringToCheck);
337345
if (timestampMatcher.find()) {
338-
stringToCheck = stringToCheck.substring(8);
346+
stringToCheck = stringToCheck.substring(timestampMatcher.end());
339347
}
340348

341349
if (textString.equals(stringToCheck)) {
@@ -481,6 +489,14 @@ private GameProfile getSender(IChatHudLine line, String text) {
481489
return sender;
482490
}
483491

492+
// Timestamps
493+
494+
private SimpleDateFormat dateFormat;
495+
496+
private void updateDateFormat() {
497+
dateFormat = new SimpleDateFormat(showSeconds.get() ? "HH:mm:ss" : "HH:mm");
498+
}
499+
484500
// Annoy
485501

486502
private String applyAnnoy(String message) {

0 commit comments

Comments
 (0)