Removing obfuscated chars from names

This commit is contained in:
Norbi Peti 2016-12-27 21:28:22 +01:00
parent 0ba39e3e30
commit 7e5ab8cbbd

View file

@ -269,10 +269,16 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
/** Removes §[char] colour codes from strings */
public static String sanitizeString(String string) {
String sanitizedString = "";
boolean random = false;
for (int i = 0; i < string.length(); i++) {
if (string.charAt(i) == '§') {
i++;// Skips the data value, the 4 in "§4Alisolarflare"
if (string.charAt(i) == 'k')
random = true;
else
random = false;
} else {
if (!random) // Skip random/obfuscated characters
sanitizedString += string.charAt(i);
}
}