diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 9a5dfc1..16e8e9d 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -157,7 +157,11 @@ public class BungeeCore extends Plugin { }, 1, 1, TimeUnit.HOURS); if (SteamwarDiscordBotConfig.loaded) { - new SteamwarDiscordBot(); + try { + new SteamwarDiscordBot(); + } catch (Exception e) { + getLogger().log(Level.SEVERE, "Could not initialize discord bot", e); + } } } @@ -168,6 +172,8 @@ public class BungeeCore extends Plugin { SteamwarDiscordBot.instance().getJda().awaitStatus(JDA.Status.SHUTDOWN); } catch (InterruptedException e) { Thread.currentThread().interrupt(); + } catch (Exception e) { + getLogger().log(Level.SEVERE, "Could not shutdown discord bot", e); } errorLogger.unregister(); diff --git a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java index 8ff2dfc..3a4c2b3 100644 --- a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java +++ b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java @@ -44,6 +44,7 @@ import javax.security.auth.login.LoginException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; public class SteamwarDiscordBot { @@ -84,7 +85,11 @@ public class SteamwarDiscordBot { } catch (InterruptedException e) { e.printStackTrace(); } - activity(); + try { + activity(); + } catch (Exception e) { + BungeeCore.get().getLogger().log(Level.SEVERE, "Could not set initial activity to discord", e); + } EventManager.update(); SchematicsManager.update(); ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { diff --git a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java index b9b0ab1..f9c589b 100644 --- a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java +++ b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java @@ -19,6 +19,7 @@ package de.steamwar.bungeecore.commands; +import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.listeners.ChatListener; @@ -28,6 +29,8 @@ import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; +import java.util.logging.Level; + public class ServerTeamchatCommand extends BasicCommand { public ServerTeamchatCommand() { @@ -51,7 +54,11 @@ public class ServerTeamchatCommand extends BasicCommand { String msg = msgBuilder.toString(); msg = ChatColor.translateAlternateColorCodes('&', msg); - SteamwarDiscordBot.instance().getServerTeamChatListener().send(" " + (player.getName() + "» " + msg).replaceAll("§[a-f0-9r]", "")); + try { + SteamwarDiscordBot.instance().getServerTeamChatListener().send(" " + (player.getName() + "» " + msg).replaceAll("§[a-f0-9r]", "")); + } catch (Exception e) { + BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send stc message to discord", e); + } sendToTeam(msg, player); } } diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 0e85917..b4ff5e9 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -37,6 +37,7 @@ import net.md_5.bungee.event.EventHandler; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; public class ChatListener extends BasicListener { @@ -203,7 +204,11 @@ public class ChatListener extends BasicListener { msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg; } - SteamwarDiscordBot.instance().getIngameChatListener().send(" " + msg.replaceAll("§[a-f0-9r]", "")); + try { + SteamwarDiscordBot.instance().getIngameChatListener().send(" " + msg.replaceAll("§[a-f0-9r]", "")); + } catch (Exception e) { + BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e); + } for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ Subserver targetServer = Subserver.getSubserver(target); if(!(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo())) continue;