From e23e4b3f66174495200f430350978839a5091601 Mon Sep 17 00:00:00 2001 From: JoeShimell <49585339+JoeShimo@users.noreply.github.com> Date: Sat, 25 Apr 2020 12:32:41 +0100 Subject: [PATCH] Fixed an error when attempting to assign player count regardless of if the bot was initialized successfully --- plugin.yml | 2 +- .../co/angrybee/joe/DiscordWhitelister.java | 19 ++++++++++--------- .../java/uk/co/angrybee/joe/VersionInfo.java | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plugin.yml b/plugin.yml index c5de53e..d16e648 100755 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,5 @@ name: DiscordWhitelister -version: 1.3.1 +version: 1.3.2 author: Joe Shimell main: uk.co.angrybee.joe.DiscordWhitelister description: Discord whitelister bot. diff --git a/src/main/java/uk/co/angrybee/joe/DiscordWhitelister.java b/src/main/java/uk/co/angrybee/joe/DiscordWhitelister.java index 98e51f4..9e0168a 100755 --- a/src/main/java/uk/co/angrybee/joe/DiscordWhitelister.java +++ b/src/main/java/uk/co/angrybee/joe/DiscordWhitelister.java @@ -112,21 +112,22 @@ public class DiscordWhitelister extends JavaPlugin if(initializeSuccess == 0) { getLogger().info("Successfully initialized Discord client."); + + // Only attempt to set player count if the bot successfully initialized + if(getWhitelisterBotConfig().getBoolean("show-player-count")) + { + // Register events if enabled + getServer().getPluginManager().registerEvents(new JoinLeaveEvents(), this); + + // Set initial player count + DiscordClient.SetPlayerCountStatus(getOnlineUsers()); + } } else if(initializeSuccess == 1) { getLogger().severe("Discord Client failed to initialize, please check if your config file is valid."); } } - - if(getWhitelisterBotConfig().getBoolean("show-player-count")) - { - // Register events if enabled - getServer().getPluginManager().registerEvents(new JoinLeaveEvents(), this); - - // Set initial player count - DiscordClient.SetPlayerCountStatus(getOnlineUsers()); - } } public static JavaPlugin getPlugin() diff --git a/src/main/java/uk/co/angrybee/joe/VersionInfo.java b/src/main/java/uk/co/angrybee/joe/VersionInfo.java index 87f7395..f71c3cb 100644 --- a/src/main/java/uk/co/angrybee/joe/VersionInfo.java +++ b/src/main/java/uk/co/angrybee/joe/VersionInfo.java @@ -9,5 +9,5 @@ public class VersionInfo { return "v." + getVersion(); } - private static String version = "1.3.1"; + private static String version = "1.3.2"; }