From f0deef80aad5d797eb0e971ac7c2be8d54223de3 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Tue, 23 Dec 2014 10:11:44 -0800 Subject: [PATCH] Fixed overzealous CAPS and similar message filters. --- .../GriefPrevention/PlayerEventHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 0be1bed..17a045e 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -350,7 +350,7 @@ class PlayerEventHandler implements Listener //if two strings are 75% identical, they're too close to follow each other in the chat private boolean stringsAreSimilar(String message, String lastMessage) { - //determine which is shorter + //determine which is shorter String shorterString, longerString; if(lastMessage.length() < message.length()) { @@ -373,16 +373,18 @@ class PlayerEventHandler implements Listener //compare forward int identicalCount = 0; - for(int i = 0; i < shorterString.length(); i++) + int i; + for(i = 0; i < shorterString.length(); i++) { if(shorterString.charAt(i) == longerString.charAt(i)) identicalCount++; if(identicalCount > maxIdenticalCharacters) return true; } //compare backward - for(int i = 0; i < shorterString.length(); i++) + int j; + for(j = 0; j < shorterString.length() - i; j++) { - if(shorterString.charAt(shorterString.length() - i - 1) == longerString.charAt(longerString.length() - i - 1)) identicalCount++; + if(shorterString.charAt(shorterString.length() - j - 1) == longerString.charAt(longerString.length() - j - 1)) identicalCount++; if(identicalCount > maxIdenticalCharacters) return true; }