Skip to content

Commit

Permalink
Optimise anti spam (MeteorDevelopment#3932)
Browse files Browse the repository at this point in the history
the J
  • Loading branch information
RacoonDog authored Aug 11, 2023
1 parent 6799f8e commit 7da4a4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void onAddMessage(Text message, @Nullable MessageSignatureData signature
for (int i = messages.size() - 1; i > -1 ; i--) {
if (((IChatHudLine) (Object) messages.get(i)).getId() == nextId && nextId != 0) {
messages.remove(i);
Modules.get().get(BetterChat.class).lines.remove(i);
Modules.get().get(BetterChat.class).lines.removeInt(i);
}
}

Expand Down Expand Up @@ -235,7 +235,7 @@ private void onRemoveMessage(Text message, MessageSignatureData signature, int t
int size = betterChat.lines.size() - (betterChat.isLongerChat() && betterChat.getChatLength() >= 100 ? betterChat.getChatLength() : 0);

while (size > 100) {
betterChat.lines.remove(size - 1);
betterChat.lines.removeInt(size - 1);
size--;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private Text appendAntiSpam(Text text) {
if (messages.isEmpty()) return null;

for (int i = 0; i < Math.min(antiSpamDepth.get(), messages.size()); i++) {
String stringToCheck = messages.get(i).content().copy().getString();
String stringToCheck = messages.get(i).content().getString();

Matcher timestampMatcher = timestampRegex.matcher(stringToCheck);
if (timestampMatcher.find()) {
Expand Down Expand Up @@ -304,17 +304,17 @@ private Text appendAntiSpam(Text text) {

int start = -1;
for (int i = 0; i < messageIndex; i++) {
start += lines.get(i);
start += lines.getInt(i);
}

int i = lines.get(messageIndex);
int i = lines.getInt(messageIndex);
while (i > 0) {
visible.remove(start + 1);
i--;
}

messages.remove(messageIndex);
lines.remove(messageIndex);
lines.removeInt(messageIndex);
}

return returnText;
Expand Down

0 comments on commit 7da4a4f

Please sign in to comment.