diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index d9155e9..aaa0e5d 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -102,6 +102,12 @@ META-INF/** + + com.artemis.the.gr8:Database:* + + META-INF/** + + diff --git a/pom.xml b/pom.xml index 8bcac55..915f3a8 100644 --- a/pom.xml +++ b/pom.xml @@ -105,6 +105,7 @@ com.tchristofferson ConfigUpdater 2.0-SNAPSHOT + compile @@ -201,6 +202,12 @@ META-INF/** + + com.artemis.the.gr8:Database:* + + META-INF/** + + diff --git a/src/main/java/com/artemis/the/gr8/playerstats/core/Main.java b/src/main/java/com/artemis/the/gr8/playerstats/core/Main.java index 30fa179..bd1075a 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/core/Main.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/core/Main.java @@ -13,7 +13,6 @@ import com.artemis.the.gr8.playerstats.core.listeners.JoinListener; import com.artemis.the.gr8.playerstats.core.msg.msgutils.LanguageKeyHandler; import com.artemis.the.gr8.playerstats.core.sharing.ShareManager; import com.artemis.the.gr8.playerstats.core.statistic.StatRequestManager; -import com.artemis.the.gr8.playerstats.core.utils.MyLogger; import com.artemis.the.gr8.playerstats.core.utils.OfflinePlayerHandler; import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.expansion.PlaceholderExpansion; @@ -69,11 +68,10 @@ public final class Main extends JavaPlugin implements PlayerStats { public void reloadPlugin() { config.reload(); - MyLogger.setDebugLevel(config.getDebugLevel()); languageKeyHandler.reload(); offlinePlayerHandler.reload(); - outputManager.updateSettings(); - shareManager.updateSettings(); + outputManager.reload(); + shareManager.reload(); } /** diff --git a/src/main/java/com/artemis/the/gr8/playerstats/core/config/ConfigHandler.java b/src/main/java/com/artemis/the/gr8/playerstats/core/config/ConfigHandler.java index 0cc22ef..fa6282c 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/core/config/ConfigHandler.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/core/config/ConfigHandler.java @@ -6,8 +6,6 @@ import com.artemis.the.gr8.playerstats.core.utils.FileHandler; import com.artemis.the.gr8.playerstats.core.utils.MyLogger; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; @@ -46,6 +44,7 @@ public final class ConfigHandler extends FileHandler { public void reload() { super.reload(); config = super.getFileConfiguration(); + MyLogger.setDebugLevel(getDebugLevel()); } /** diff --git a/src/main/java/com/artemis/the/gr8/playerstats/core/msg/OutputManager.java b/src/main/java/com/artemis/the/gr8/playerstats/core/msg/OutputManager.java index cbac752..6e77af6 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/core/msg/OutputManager.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/core/msg/OutputManager.java @@ -6,6 +6,7 @@ import com.artemis.the.gr8.playerstats.core.enums.StandardMessage; import com.artemis.the.gr8.playerstats.core.msg.components.*; import com.artemis.the.gr8.playerstats.core.msg.msgutils.FormattingFunction; import com.artemis.the.gr8.playerstats.api.StatRequest; +import com.artemis.the.gr8.playerstats.core.utils.Reloadable; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.text.TextComponent; import org.bukkit.Bukkit; @@ -29,7 +30,7 @@ import static com.artemis.the.gr8.playerstats.core.enums.StandardMessage.*; * for Players (mainly to deal with the lack of hover-text, * and for Bukkit consoles to make up for the lack of hex-colors). */ -public final class OutputManager { +public final class OutputManager implements Reloadable { private static BukkitAudiences adventure; private static EnumMap> standardMessages; @@ -46,7 +47,7 @@ public final class OutputManager { prepareFunctions(); } - public void updateSettings() { + public void reload() { getMessageBuilders(); } diff --git a/src/main/java/com/artemis/the/gr8/playerstats/core/sharing/ShareManager.java b/src/main/java/com/artemis/the/gr8/playerstats/core/sharing/ShareManager.java index 0af4aad..de5c12b 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/core/sharing/ShareManager.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/core/sharing/ShareManager.java @@ -2,6 +2,7 @@ package com.artemis.the.gr8.playerstats.core.sharing; import com.artemis.the.gr8.playerstats.core.config.ConfigHandler; import com.artemis.the.gr8.playerstats.core.utils.MyLogger; +import com.artemis.the.gr8.playerstats.core.utils.Reloadable; import net.kyori.adventure.text.TextComponent; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; @@ -23,7 +24,7 @@ import static java.time.temporal.ChronoUnit.SECONDS; * of past stat-lookups, so the results can be retrieved * and shared when a Player clicks the share-button. */ -public final class ShareManager { +public final class ShareManager implements Reloadable { private static volatile ShareManager instance; private static boolean isEnabled; @@ -35,7 +36,7 @@ public final class ShareManager { private ArrayBlockingQueue sharedResults; private ShareManager() { - updateSettings(); + reload(); } public static ShareManager getInstance() { @@ -56,7 +57,7 @@ public final class ShareManager { return isEnabled; } - public void updateSettings() { + public void reload() { ConfigHandler config = ConfigHandler.getInstance(); isEnabled = config.allowStatSharing() && config.useHoverText(); waitingTime = config.getStatShareWaitingTime(); diff --git a/src/main/java/com/artemis/the/gr8/playerstats/core/utils/FileHandler.java b/src/main/java/com/artemis/the/gr8/playerstats/core/utils/FileHandler.java index 7ea1837..a792027 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/core/utils/FileHandler.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/core/utils/FileHandler.java @@ -14,7 +14,7 @@ import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; -public abstract class FileHandler { +public abstract class FileHandler implements Reloadable { private final String fileName; private File file; diff --git a/src/main/java/com/artemis/the/gr8/playerstats/core/utils/Reloadable.java b/src/main/java/com/artemis/the/gr8/playerstats/core/utils/Reloadable.java new file mode 100644 index 0000000..287d81a --- /dev/null +++ b/src/main/java/com/artemis/the/gr8/playerstats/core/utils/Reloadable.java @@ -0,0 +1,6 @@ +package com.artemis.the.gr8.playerstats.core.utils; + +public interface Reloadable { + + void reload(); +} \ No newline at end of file