diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java index c0093d7974..200c002963 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java @@ -116,7 +116,7 @@ private void onAddMessage(Text message, MessageSignatureData signatureData, Mess for (int i = messages.size() - 1; i > -1; i--) { if (((IChatHudLine) (Object) messages.get(i)).meteor$getId() == nextId && nextId != 0) { messages.remove(i); - Modules.get().get(BetterChat.class).lines.removeInt(i); + getBetterChat().removeLine(i); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java index 0400733503..8bd07ffd53 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java @@ -292,6 +292,32 @@ private void onMessageReceive(ReceiveMessageEvent event) { event.setMessage(message); } + @EventHandler + private void onMessageSend(SendMessageEvent event) { + String message = event.message; + + if (annoy.get()) message = applyAnnoy(message); + + if (fancy.get()) message = applyFancy(message); + + message = getPrefix() + message + getSuffix(); + + if (coordsProtection.get() && containsCoordinates(message)) { + MutableText warningMessage = Text.literal("It looks like there are coordinates in your message! "); + + MutableText sendButton = getSendButton(message); + warningMessage.append(sendButton); + + ChatUtils.sendMsg(warningMessage); + + event.cancel(); + return; + } + + event.message = message; + } + + // Anti Spam private Text appendAntiSpam(Text text) { String textString = text.getString(); @@ -349,29 +375,17 @@ private Text appendAntiSpam(Text text) { return returnText; } - @EventHandler - private void onMessageSend(SendMessageEvent event) { - String message = event.message; - - if (annoy.get()) message = applyAnnoy(message); - - if (fancy.get()) message = applyFancy(message); - - message = getPrefix() + message + getSuffix(); - - if (coordsProtection.get() && containsCoordinates(message)) { - MutableText warningMessage = Text.literal("It looks like there are coordinates in your message! "); - - MutableText sendButton = getSendButton(message); - warningMessage.append(sendButton); - - ChatUtils.sendMsg(warningMessage); + public void removeLine(int index) { + if (index >= lines.size()) { + if (antiSpam.get()) { + error("Issue detected with the anti-spam system! Likely a compatibility issue with another mod. Disabling anti-spam to protect chat integrity."); + antiSpam.set(false); + } - event.cancel(); return; } - event.message = message; + lines.removeInt(index); } // Player Heads