(#12) Added ping and removing color codes

This commit is contained in:
Norbi Peti 2016-12-01 21:51:12 +01:00
parent 97c568a662
commit ebf862e54a

View file

@ -103,8 +103,18 @@ public class DiscordSender implements CommandSender {
@Override @Override
public void sendMessage(String message) { public void sendMessage(String message) {
try { try {
Bukkit.getScheduler().runTaskAsynchronously(DiscordPlugin.plugin, final boolean broadcast = new Exception().getStackTrace()[1].getMethodName().contains("broadcast");
() -> DiscordPlugin.sendMessageToChannel(channel, message)); String sanitizedMsg = "";
for (int i = 0; i < message.length(); i++) {
if (message.charAt(i) != '§') {
sanitizedMsg += message.charAt(i);
} else {
i++;
}
}
final String sendmsg = sanitizedMsg;
Bukkit.getScheduler().runTaskAsynchronously(DiscordPlugin.plugin, () -> DiscordPlugin
.sendMessageToChannel(channel, (broadcast ? user.mention() + " " : "") + sendmsg));
} catch (Exception e) { } catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while sending message to DiscordSender", e); TBMCCoreAPI.SendException("An error occured while sending message to DiscordSender", e);
} }