diff --git a/src/main/java/me/jaimemartz/lobbybalancer/LobbyBalancer.java b/src/main/java/me/jaimemartz/lobbybalancer/LobbyBalancer.java index 4a7c9af..533ae01 100644 --- a/src/main/java/me/jaimemartz/lobbybalancer/LobbyBalancer.java +++ b/src/main/java/me/jaimemartz/lobbybalancer/LobbyBalancer.java @@ -1,5 +1,6 @@ package me.jaimemartz.lobbybalancer; +import lombok.Getter; import me.jaimemartz.faucet.ConfigFactory; import me.jaimemartz.lobbybalancer.commands.FallbackCommand; import me.jaimemartz.lobbybalancer.commands.MainCommand; @@ -27,11 +28,12 @@ public class LobbyBalancer extends Plugin { public static final String NONCE_ID = "%%__NONCE__%%"; private static final int LAST_VER_CONFIG_UPDATE = 20950; - private boolean failed = false; + @Getter private ConfigFactory factory; + @Getter private boolean failed = false; + @Getter private StatusManager statusManager; + @Getter private SectionManager sectionManager; + @Getter private static LobbyBalancer instance; - private ConfigFactory factory; - private StatusManager statusManager; - private SectionManager sectionManager; private Command fallbackCommand, mainCommand, manageCommand; private Listener connectListener, kickListener, messageListener, reloadListener; @@ -139,7 +141,7 @@ public class LobbyBalancer extends Plugin { if (ConfigEntries.PLUGIN_ENABLED.get()) { //Do not try to do anything if the plugin has not loaded correctly - if (hasFailed()) return; + if (isFailed()) return; if (ConfigEntries.AUTO_RELOAD_ENABLED.get()) { getProxy().getPluginManager().unregisterListener(reloadListener); @@ -190,24 +192,7 @@ public class LobbyBalancer extends Plugin { getLogger().info(String.format("The plugin has been reloaded, took %sms", ending)); } - public StatusManager getStatusManager() { - return statusManager; - } - - public SectionManager getSectionManager() { - return sectionManager; - } - - public boolean hasFailed() { - return failed; - } - - public Configuration getConfig() { - return factory.get(0).getHandle(); - } - - private static LobbyBalancer instance; - public static LobbyBalancer getInstance() { - return instance; + public Configuration getConfigHandle() { + return factory.get("config.yml").getHandle(); } } diff --git a/src/main/java/me/jaimemartz/lobbybalancer/commands/FallbackCommand.java b/src/main/java/me/jaimemartz/lobbybalancer/commands/FallbackCommand.java index 96aa9c3..1df5e57 100644 --- a/src/main/java/me/jaimemartz/lobbybalancer/commands/FallbackCommand.java +++ b/src/main/java/me/jaimemartz/lobbybalancer/commands/FallbackCommand.java @@ -37,7 +37,7 @@ public class FallbackCommand extends Command { return null; } - Configuration rules = plugin.getConfig().getSection("settings.fallback-command.rules"); + Configuration rules = plugin.getConfigHandle().getSection("settings.fallback-command.rules"); String bind = rules.getString(section.getName()); ServerSection target = plugin.getSectionManager().getByName(bind); diff --git a/src/main/java/me/jaimemartz/lobbybalancer/listener/ServerKickListener.java b/src/main/java/me/jaimemartz/lobbybalancer/listener/ServerKickListener.java index 9f2b288..f0def5a 100644 --- a/src/main/java/me/jaimemartz/lobbybalancer/listener/ServerKickListener.java +++ b/src/main/java/me/jaimemartz/lobbybalancer/listener/ServerKickListener.java @@ -76,7 +76,7 @@ public class ServerKickListener implements Listener { if (matches.get()) { if (section != null) { - Configuration rules = plugin.getConfig().getSection("settings.reconnect-kick.rules"); + Configuration rules = plugin.getConfigHandle().getSection("settings.reconnect-kick.rules"); String name = rules.getString(section.getName()); ServerSection target = plugin.getSectionManager().getByName(name); diff --git a/src/main/java/me/jaimemartz/lobbybalancer/section/SectionManager.java b/src/main/java/me/jaimemartz/lobbybalancer/section/SectionManager.java index 5915317..a99bc56 100644 --- a/src/main/java/me/jaimemartz/lobbybalancer/section/SectionManager.java +++ b/src/main/java/me/jaimemartz/lobbybalancer/section/SectionManager.java @@ -29,7 +29,8 @@ public class SectionManager { plugin.getLogger().info("Loading sections from the config, this may take a while..."); long starting = System.currentTimeMillis(); - Configuration sections = plugin.getConfig().getSection("sections"); + Configuration sections = plugin.getConfigHandle().getSection("sections"); + sections.getKeys().forEach(name -> { plugin.getLogger().info(String.format("Construction of section with name \"%s\"", name)); Configuration section = sections.getSection(name);