Removing obfuscated chars from names
This commit is contained in:
parent
0ba39e3e30
commit
7e5ab8cbbd
1 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue