fixed antiswear removeColors()
This commit is contained in:
@@ -9,7 +9,10 @@ import net.md_5.bungee.api.chat.HoverEvent;
|
|||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
public class ChatConstraints {
|
public class ChatConstraints {
|
||||||
@@ -96,8 +99,10 @@ public class ChatConstraints {
|
|||||||
// 3
|
// 3
|
||||||
for (String whitelisted : Config.Chat.AntiSwear.whitelist()) {
|
for (String whitelisted : Config.Chat.AntiSwear.whitelist()) {
|
||||||
String key = whitelisted.toLowerCase().replaceAll(" ", "");
|
String key = whitelisted.toLowerCase().replaceAll(" ", "");
|
||||||
|
if (msg.contains(key)) {
|
||||||
msg = msg.replaceAll(key, "").trim();
|
msg = msg.replaceAll(key, "").trim();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 4
|
// 4
|
||||||
msg = msg.replaceAll("[. _-]", "");
|
msg = msg.replaceAll("[. _-]", "");
|
||||||
// 5
|
// 5
|
||||||
@@ -129,9 +134,12 @@ public class ChatConstraints {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String removeColors(String msg) {
|
private String removeColors(String msg) {
|
||||||
return String.join(" ", Arrays.stream(msg.split(" "))
|
String s = msg;
|
||||||
.filter(s -> !(s.length() >= 1 && s.charAt(0) == '§'))
|
while (s.length() >= 2 && s.contains("§")) {
|
||||||
.toList());
|
int index = s.indexOf("§");
|
||||||
|
s = s.replaceAll(s.substring(index, index + 2), "");
|
||||||
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getChatCooldown() {
|
public double getChatCooldown() {
|
||||||
|
|||||||
Reference in New Issue
Block a user