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

@ -228,7 +228,7 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
} }
try { try {
if (channel == chatchannel) if (channel == chatchannel)
MCChatListener.resetLastMessage(); //If this is a chat message, it'll be set again MCChatListener.resetLastMessage(); // If this is a chat message, it'll be set again
final String content = TBMCCoreAPI.IsTestServer() && channel != chatchannel final String content = TBMCCoreAPI.IsTestServer() && channel != chatchannel
? "*The following message is from a test server*\n" + message : message; ? "*The following message is from a test server*\n" + message : message;
return embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false); return embed == null ? channel.sendMessage(content) : channel.sendMessage(content, embed, false);
@ -269,11 +269,17 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
/** Removes §[char] colour codes from strings */ /** Removes §[char] colour codes from strings */
public static String sanitizeString(String string) { public static String sanitizeString(String string) {
String sanitizedString = ""; String sanitizedString = "";
boolean random = false;
for (int i = 0; i < string.length(); i++) { for (int i = 0; i < string.length(); i++) {
if (string.charAt(i) == '§') { if (string.charAt(i) == '§') {
i++;// Skips the data value, the 4 in "§4Alisolarflare" i++;// Skips the data value, the 4 in "§4Alisolarflare"
if (string.charAt(i) == 'k')
random = true;
else
random = false;
} else { } else {
sanitizedString += string.charAt(i); if (!random) // Skip random/obfuscated characters
sanitizedString += string.charAt(i);
} }
} }
return sanitizedString; return sanitizedString;