Merge pull request #14 from TBMCPlugins/Feature

Removed colour codes from messages
This commit is contained in:
Norbi Peti 2016-12-06 21:30:36 +01:00 committed by GitHub
commit 2e00849303

View file

@ -30,8 +30,22 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
return;
if (e.getChannel().equals(Channel.GlobalChat))
DiscordPlugin.sendMessageToChannel(DiscordPlugin.chatchannel, "<" + (e.getSender() instanceof Player
? ((Player) e.getSender()).getDisplayName() : e.getSender().getName()) + "> " + e.getMessage());
? sanitizeString(((Player) e.getSender()).getDisplayName()) :
sanitizeString(e.getSender().getName())) + "> " + sanitizeString(e.getMessage()));
}
/**Removes §[char] colour codes from strings*/
private String sanitizeString(String string){
String sanitizedString = "";
for(int i = 0; i < string.length(); i++){
if (string.charAt(i) == '§'){
i++;//Skips the data value, the 4 in "§4Alisolarflare"
}else{
sanitizedString += string.charAt(i);
}
}
return sanitizedString;
}
private static final String[] UnconnectedCmds = new String[] { "list", "u", "shrug", "tableflip", "unflip",
"mwiki" };