From e306567ca50046b9103dbc902f9503602778a721 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 4 Mar 2022 23:46:00 +0100 Subject: [PATCH 1/5] Fix discord bot loading --- src/de/steamwar/bungeecore/BungeeCore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index b3be7cb2..20b9b461 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -278,7 +278,7 @@ public class BungeeCore extends Plugin { config.getString("db.password") ); - if (config.getSection("discord") != null) { + if (config.contains("discord")) { SteamwarDiscordBotConfig.loadConfig(config.getSection("discord")); } From a0aea29b1b74f4783af8d433def2cf02a7966648 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 4 Mar 2022 23:46:21 +0100 Subject: [PATCH 2/5] Fix discord bot loading --- src/de/steamwar/bungeecore/BungeeCore.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 20b9b461..84b020a6 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -172,10 +172,12 @@ public class BungeeCore extends Plugin { @Override public void onDisable(){ - try { - SteamwarDiscordBot.instance().getJda().shutdown(); - } catch (Throwable e) { - getLogger().log(Level.SEVERE, "Could not shutdown discord bot", e); + if (SteamwarDiscordBotConfig.loaded) { + try { + SteamwarDiscordBot.instance().getJda().shutdown(); + } catch (Throwable e) { + getLogger().log(Level.SEVERE, "Could not shutdown discord bot", e); + } } errorLogger.unregister(); From a5669ef7e2b1baa77398b5db48b55061096652e0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 5 Mar 2022 12:25:45 +0100 Subject: [PATCH 3/5] Fix possible exceptions --- src/de/steamwar/bungeecore/commands/AlertCommand.java | 2 +- .../bungeecore/commands/ServerTeamchatCommand.java | 10 ++++++---- src/de/steamwar/bungeecore/listeners/ChatListener.java | 10 ++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/AlertCommand.java b/src/de/steamwar/bungeecore/commands/AlertCommand.java index db7c3b01..a271cf8e 100644 --- a/src/de/steamwar/bungeecore/commands/AlertCommand.java +++ b/src/de/steamwar/bungeecore/commands/AlertCommand.java @@ -51,7 +51,7 @@ public class AlertCommand extends BasicCommand { } Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', s)); - if (discordAnnounce) { + if (discordAnnounce && SteamwarDiscordBot.instance() != null) { SteamwarDiscordBot.instance().getAnnouncementListener().announce(s); } } diff --git a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java index f9c589b2..7207e0a2 100644 --- a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java +++ b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java @@ -54,10 +54,12 @@ public class ServerTeamchatCommand extends BasicCommand { String msg = msgBuilder.toString(); msg = ChatColor.translateAlternateColorCodes('&', msg); - 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); + if (SteamwarDiscordBot.instance() != null) { + 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 f66e71cd..96c628a4 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -212,10 +212,12 @@ public class ChatListener extends BasicListener { msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg; } - 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); + if (SteamwarDiscordBot.instance() != null) { + 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); From 93abe90b1a7d0ce0009d6dcb1eb183f5f99af58b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 5 Mar 2022 16:54:51 +0100 Subject: [PATCH 4/5] Fix exceptions Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/ConnectionListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java index 9506ea2d..65855b39 100644 --- a/src/de/steamwar/bungeecore/listeners/ConnectionListener.java +++ b/src/de/steamwar/bungeecore/listeners/ConnectionListener.java @@ -23,6 +23,7 @@ import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Subserver; +import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.bot.util.DiscordRanks; import de.steamwar.bungeecore.commands.ChallengeCommand; import de.steamwar.bungeecore.commands.CheckCommand; @@ -96,7 +97,8 @@ public class ConnectionListener extends BasicListener { newPlayers.remove(player.getUniqueId()); } - DiscordRanks.update(user); + if(SteamwarDiscordBotConfig.loaded) + DiscordRanks.update(user); } /** To redirect players to the lobby in case of server closure. */ From a3e1db4fbb75fcf8cdc249fdafaa5d04da6102be Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 6 Mar 2022 16:57:25 +0100 Subject: [PATCH 5/5] Fix Forge 1.12.2 Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/listeners/mods/Forge.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index c29a03cb..c936dd0f 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -61,7 +61,7 @@ public class Forge extends BasicListener { @EventHandler public void onServerConnected(LoginEvent event){ - if(event.getConnection().getVersion() < 340) return; //1.13+ + if(event.getConnection().getVersion() < 341) return; //1.13+ //fml:handshake without mods, channels and registries //for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29