From 1dfcfb958653db266063edf4afe9a0f0cad85330 Mon Sep 17 00:00:00 2001 From: Joe Shimell <49585339+JoeShimell@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:27:51 +0100 Subject: [PATCH] Pass through vanished player count if reloading --- .../uk/co/angrybee/joe/Commands/CommandReload.java | 2 +- .../java/uk/co/angrybee/joe/DiscordWhitelister.java | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/uk/co/angrybee/joe/Commands/CommandReload.java b/src/main/java/uk/co/angrybee/joe/Commands/CommandReload.java index cab2f57..b9bcbbd 100644 --- a/src/main/java/uk/co/angrybee/joe/Commands/CommandReload.java +++ b/src/main/java/uk/co/angrybee/joe/Commands/CommandReload.java @@ -33,7 +33,7 @@ public class CommandReload implements CommandExecutor } // initializes client - int initSuccess = DiscordWhitelister.InitBot(); + int initSuccess = DiscordWhitelister.InitBot(false); if(initSuccess == 1) { diff --git a/src/main/java/uk/co/angrybee/joe/DiscordWhitelister.java b/src/main/java/uk/co/angrybee/joe/DiscordWhitelister.java index abbef25..a784cfc 100755 --- a/src/main/java/uk/co/angrybee/joe/DiscordWhitelister.java +++ b/src/main/java/uk/co/angrybee/joe/DiscordWhitelister.java @@ -58,7 +58,7 @@ public class DiscordWhitelister extends JavaPlugin thisServer = thisPlugin.getServer(); pluginLogger = thisPlugin.getLogger(); - int initSuccess = InitBot(); + int initSuccess = InitBot(true); if(initSuccess == 0) { @@ -137,13 +137,15 @@ public class DiscordWhitelister extends JavaPlugin public static int getMaximumAllowedPlayers() { return thisPlugin.getServer().getMaxPlayers(); } - public static int InitBot() + public static int InitBot(boolean firstInit) { whitelisterBotConfig = new YamlConfiguration(); userList = new YamlConfiguration(); removedList = new YamlConfiguration(); customMessagesConfig = new YamlConfiguration(); - vanishedPlayersCount = 0; // TODO: check if this messes up when reloading the bot + + if(firstInit) + vanishedPlayersCount = 0; ConfigSetup(); @@ -204,9 +206,7 @@ public class DiscordWhitelister extends JavaPlugin // Custom messages check if(getWhitelisterBotConfig().getBoolean("use-custom-messages")) - { useCustomMessages = true; - } int initSuccess = DiscordClient.InitializeClient(botToken); @@ -240,7 +240,6 @@ public class DiscordWhitelister extends JavaPlugin removedListFile = new File(dataFolder, "removed-list.yml"); customMessagesFile = new File(dataFolder, "custom-messages.yml"); - if(!whitelisterBotConfigFile.getParentFile().exists()) { whitelisterBotConfigFile.getParentFile().mkdirs();