From 6205a61bb082b58e98b9cae316a81ffb437d05c8 Mon Sep 17 00:00:00 2001 From: Jaime Martinez Rincon Date: Wed, 9 Aug 2017 20:06:18 +0200 Subject: [PATCH] Progress on migrating to properties --- .../playerbalancer/PlayerBalancer.java | 28 +++++++++++-------- .../playerbalancer/ping/StatusManager.java | 1 - .../settings/types/CheckerProperties.java | 6 ++-- .../settings/types/ReconnectorProperties.java | 4 --- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java b/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java index 378250b..7d8abc3 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java +++ b/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java @@ -13,6 +13,10 @@ import com.jaimemartz.playerbalancer.ping.StatusManager; import com.jaimemartz.playerbalancer.section.SectionManager; import com.jaimemartz.playerbalancer.settings.Settings; import com.jaimemartz.playerbalancer.settings.SettingsProvider; +import com.jaimemartz.playerbalancer.settings.types.CheckerProperties; +import com.jaimemartz.playerbalancer.settings.types.CommandProperties; +import com.jaimemartz.playerbalancer.settings.types.GeneralProperties; +import com.jaimemartz.playerbalancer.settings.types.ReconnectorProperties; import lombok.Getter; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.plugin.Command; @@ -63,12 +67,12 @@ public class PlayerBalancer extends Plugin { mainCommand = new MainCommand(this); getProxy().getPluginManager().registerCommand(this, mainCommand); - if (ConfigEntries.PLUGIN_ENABLED.get()) { - if (ConfigEntries.SILENT_STARTUP.get()) { + if (settings.getProperty(GeneralProperties.ENABLED)) { + if (settings.getProperty(GeneralProperties.SILENT)) { getLogger().setLevel(Level.WARNING); } - if (ConfigEntries.AUTO_RELOAD_ENABLED.get()) { + if (settings.getProperty(GeneralProperties.AUTO_RELOAD)) { reloadListener = new ProxyReloadListener(this); getProxy().getPluginManager().registerListener(this, reloadListener); } @@ -85,11 +89,11 @@ public class PlayerBalancer extends Plugin { sectionManager.load(); statusManager = new StatusManager(); - if (ConfigEntries.SERVER_CHECK_ENABLED.get()) { + if (settings.getProperty(CheckerProperties.ENABLED)) { statusManager.start(this); } - if (ConfigEntries.FALLBACK_COMMAND_ENABLED.get()) { + if (settings.getProperty(CommandProperties.ENABLED)) { fallbackCommand = new FallbackCommand(this); getProxy().getPluginManager().registerCommand(this, fallbackCommand); } @@ -109,7 +113,7 @@ public class PlayerBalancer extends Plugin { Stream.of(PasteHelper.values()).forEach(a -> a.setUrl(null)); - if (ConfigEntries.RECONNECT_KICK_ENABLED.get()) { + if (settings.getProperty(ReconnectorProperties.ENABLED)) { kickListener = new ServerKickListener(this); getProxy().getPluginManager().registerListener(this, kickListener); } @@ -139,20 +143,20 @@ public class PlayerBalancer extends Plugin { getProxy().getPluginManager().unregisterCommand(mainCommand); mainCommand = null; - if (ConfigEntries.PLUGIN_ENABLED.get()) { + if (settings.getProperty(GeneralProperties.ENABLED)) { //Do not try to do anything if the plugin has not loaded correctly if (isFailed()) return; - if (ConfigEntries.AUTO_RELOAD_ENABLED.get()) { + if (settings.getProperty(GeneralProperties.AUTO_RELOAD)) { getProxy().getPluginManager().unregisterListener(reloadListener); reloadListener = null; } - if (ConfigEntries.SERVER_CHECK_ENABLED.get()) { + if (settings.getProperty(CheckerProperties.ENABLED)) { statusManager.stop(); } - if (ConfigEntries.FALLBACK_COMMAND_ENABLED.get()) { + if (settings.getProperty(CommandProperties.ENABLED)) { getProxy().getPluginManager().unregisterCommand(fallbackCommand); fallbackCommand = null; } @@ -166,14 +170,14 @@ public class PlayerBalancer extends Plugin { getProxy().getPluginManager().unregisterCommand(manageCommand); manageCommand = null; - if (ConfigEntries.RECONNECT_KICK_ENABLED.get()) { + if (settings.getProperty(ReconnectorProperties.ENABLED)) { getProxy().getPluginManager().unregisterListener(kickListener); kickListener = null; } sectionManager.flush(); - if (ConfigEntries.ASSIGN_TARGETS_ENABLED.get()) { + if (settings.getProperty(GeneralProperties.ASSIGN_TARGETS)) { ServerAssignRegistry.getTable().clear(); } } diff --git a/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java b/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java index 4f5f530..2ee510b 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java +++ b/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java @@ -2,7 +2,6 @@ package com.jaimemartz.playerbalancer.ping; import com.jaimemartz.playerbalancer.PlayerBalancer; import com.jaimemartz.playerbalancer.section.ServerSection; -import com.jaimemartz.playerbalancer.settings.ConfigEntries; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.scheduler.ScheduledTask; diff --git a/src/main/java/com/jaimemartz/playerbalancer/settings/types/CheckerProperties.java b/src/main/java/com/jaimemartz/playerbalancer/settings/types/CheckerProperties.java index 2e2a44b..cd1dc05 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/settings/types/CheckerProperties.java +++ b/src/main/java/com/jaimemartz/playerbalancer/settings/types/CheckerProperties.java @@ -20,10 +20,10 @@ public class CheckerProperties implements SettingsHolder { public static final Property TIMEOUT = newProperty("settings.server-check.timeout", 5000); - public static final Property DEBUG = newProperty("settings.server-check.print-info", false); - - public static final Property> MARKER_DESCS = newListProperty("settings.server-check.print-info", + public static final Property> MARKER_DESCS = newListProperty("settings.server-check.marker-descs", "Sever is not accessible", "Gamemode has already started" ); + + public static final Property DEBUG = newProperty("settings.server-check.print-info", false); } diff --git a/src/main/java/com/jaimemartz/playerbalancer/settings/types/ReconnectorProperties.java b/src/main/java/com/jaimemartz/playerbalancer/settings/types/ReconnectorProperties.java index b8d6bc9..02e15cc 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/settings/types/ReconnectorProperties.java +++ b/src/main/java/com/jaimemartz/playerbalancer/settings/types/ReconnectorProperties.java @@ -18,12 +18,8 @@ public class ReconnectorProperties implements SettingsHolder { public static final Property> IGNORED_SECTIONS = newListProperty("settings.reconnect-kick.ignored"); - public static final Property RESTRICTED = newProperty("settings.reconnect-kick.restricted", true); - //todo is it really necessary? - public static final Property EXCLUDE_FROM = newProperty("settings.reconnect-kick.exclude-from", true); - public static final Property FORCE_PRINCIPAL = newProperty("settings.reconnect-kick.force-principal", false); public static final Property RULES = newBeanProperty(MapBean.class, "settings.reconnect-kick",