From 0cdcfc12a82e916f8d56e7145861f7551acfd377 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 27 Sep 2021 16:42:07 +0200 Subject: [PATCH 1/2] Update DiscordBot integration --- src/de/steamwar/bungeecore/BungeeCore.java | 8 ++++++-- .../bungeecore/bot/config/SteamwarDiscordBotConfig.java | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 0b71cb5..6b46fbb 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -154,7 +154,9 @@ public class BungeeCore extends Plugin { Team.clearCache(); }, 1, 1, TimeUnit.HOURS); - new SteamwarDiscordBot(); + if (SteamwarDiscordBotConfig.loaded) { + new SteamwarDiscordBot(); + } } @Override @@ -267,7 +269,9 @@ public class BungeeCore extends Plugin { ); ArenaMode.init(config.getSection("games")); - SteamwarDiscordBotConfig.loadConfig(config.getSection("discord")); + if (config.getSection("discord") != null) { + SteamwarDiscordBotConfig.loadConfig(config.getSection("discord")); + } final Configuration servers = config.getSection("servers"); for(final String serverName : servers.getKeys()){ diff --git a/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java b/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java index f69a3ac..34c65e8 100644 --- a/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java +++ b/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java @@ -29,6 +29,7 @@ import java.util.Map; public class SteamwarDiscordBotConfig { + public static boolean loaded = false; public static String TOKEN; public static String GUILD; public static String ANNOUNCEMENTS_CHANNEL; @@ -110,5 +111,6 @@ public class SteamwarDiscordBotConfig { for (String type : ranksSections.getKeys()) { RANKS.put(UserGroup.getUsergroup(type), ranksSections.getString(type)); } + loaded = true; } } From c51415443f0931b0f0f6fdfe52dfa57eb76f37db Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 27 Sep 2021 16:46:26 +0200 Subject: [PATCH 2/2] Fix Node NumberFormatException --- src/de/steamwar/bungeecore/Node.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/Node.java b/src/de/steamwar/bungeecore/Node.java index ea0a2ed..465778c 100644 --- a/src/de/steamwar/bungeecore/Node.java +++ b/src/de/steamwar/bungeecore/Node.java @@ -191,7 +191,7 @@ public abstract class Node { int c; try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { c = Integer.parseInt(bufferedReader.readLine()); - } catch (IOException e) { + } catch (IOException | NumberFormatException e) { BungeeCore.get().getLogger().log(Level.SEVERE, "Could not read cores of" + remote, e); c = 1; }