mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-09 04:20:32 +01:00
Progress on migrating to properties
This commit is contained in:
parent
65930a7510
commit
6205a61bb0
@ -13,6 +13,10 @@ import com.jaimemartz.playerbalancer.ping.StatusManager;
|
|||||||
import com.jaimemartz.playerbalancer.section.SectionManager;
|
import com.jaimemartz.playerbalancer.section.SectionManager;
|
||||||
import com.jaimemartz.playerbalancer.settings.Settings;
|
import com.jaimemartz.playerbalancer.settings.Settings;
|
||||||
import com.jaimemartz.playerbalancer.settings.SettingsProvider;
|
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 lombok.Getter;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
@ -63,12 +67,12 @@ public class PlayerBalancer extends Plugin {
|
|||||||
mainCommand = new MainCommand(this);
|
mainCommand = new MainCommand(this);
|
||||||
getProxy().getPluginManager().registerCommand(this, mainCommand);
|
getProxy().getPluginManager().registerCommand(this, mainCommand);
|
||||||
|
|
||||||
if (ConfigEntries.PLUGIN_ENABLED.get()) {
|
if (settings.getProperty(GeneralProperties.ENABLED)) {
|
||||||
if (ConfigEntries.SILENT_STARTUP.get()) {
|
if (settings.getProperty(GeneralProperties.SILENT)) {
|
||||||
getLogger().setLevel(Level.WARNING);
|
getLogger().setLevel(Level.WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntries.AUTO_RELOAD_ENABLED.get()) {
|
if (settings.getProperty(GeneralProperties.AUTO_RELOAD)) {
|
||||||
reloadListener = new ProxyReloadListener(this);
|
reloadListener = new ProxyReloadListener(this);
|
||||||
getProxy().getPluginManager().registerListener(this, reloadListener);
|
getProxy().getPluginManager().registerListener(this, reloadListener);
|
||||||
}
|
}
|
||||||
@ -85,11 +89,11 @@ public class PlayerBalancer extends Plugin {
|
|||||||
sectionManager.load();
|
sectionManager.load();
|
||||||
|
|
||||||
statusManager = new StatusManager();
|
statusManager = new StatusManager();
|
||||||
if (ConfigEntries.SERVER_CHECK_ENABLED.get()) {
|
if (settings.getProperty(CheckerProperties.ENABLED)) {
|
||||||
statusManager.start(this);
|
statusManager.start(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntries.FALLBACK_COMMAND_ENABLED.get()) {
|
if (settings.getProperty(CommandProperties.ENABLED)) {
|
||||||
fallbackCommand = new FallbackCommand(this);
|
fallbackCommand = new FallbackCommand(this);
|
||||||
getProxy().getPluginManager().registerCommand(this, fallbackCommand);
|
getProxy().getPluginManager().registerCommand(this, fallbackCommand);
|
||||||
}
|
}
|
||||||
@ -109,7 +113,7 @@ public class PlayerBalancer extends Plugin {
|
|||||||
|
|
||||||
Stream.of(PasteHelper.values()).forEach(a -> a.setUrl(null));
|
Stream.of(PasteHelper.values()).forEach(a -> a.setUrl(null));
|
||||||
|
|
||||||
if (ConfigEntries.RECONNECT_KICK_ENABLED.get()) {
|
if (settings.getProperty(ReconnectorProperties.ENABLED)) {
|
||||||
kickListener = new ServerKickListener(this);
|
kickListener = new ServerKickListener(this);
|
||||||
getProxy().getPluginManager().registerListener(this, kickListener);
|
getProxy().getPluginManager().registerListener(this, kickListener);
|
||||||
}
|
}
|
||||||
@ -139,20 +143,20 @@ public class PlayerBalancer extends Plugin {
|
|||||||
getProxy().getPluginManager().unregisterCommand(mainCommand);
|
getProxy().getPluginManager().unregisterCommand(mainCommand);
|
||||||
mainCommand = null;
|
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
|
//Do not try to do anything if the plugin has not loaded correctly
|
||||||
if (isFailed()) return;
|
if (isFailed()) return;
|
||||||
|
|
||||||
if (ConfigEntries.AUTO_RELOAD_ENABLED.get()) {
|
if (settings.getProperty(GeneralProperties.AUTO_RELOAD)) {
|
||||||
getProxy().getPluginManager().unregisterListener(reloadListener);
|
getProxy().getPluginManager().unregisterListener(reloadListener);
|
||||||
reloadListener = null;
|
reloadListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntries.SERVER_CHECK_ENABLED.get()) {
|
if (settings.getProperty(CheckerProperties.ENABLED)) {
|
||||||
statusManager.stop();
|
statusManager.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntries.FALLBACK_COMMAND_ENABLED.get()) {
|
if (settings.getProperty(CommandProperties.ENABLED)) {
|
||||||
getProxy().getPluginManager().unregisterCommand(fallbackCommand);
|
getProxy().getPluginManager().unregisterCommand(fallbackCommand);
|
||||||
fallbackCommand = null;
|
fallbackCommand = null;
|
||||||
}
|
}
|
||||||
@ -166,14 +170,14 @@ public class PlayerBalancer extends Plugin {
|
|||||||
getProxy().getPluginManager().unregisterCommand(manageCommand);
|
getProxy().getPluginManager().unregisterCommand(manageCommand);
|
||||||
manageCommand = null;
|
manageCommand = null;
|
||||||
|
|
||||||
if (ConfigEntries.RECONNECT_KICK_ENABLED.get()) {
|
if (settings.getProperty(ReconnectorProperties.ENABLED)) {
|
||||||
getProxy().getPluginManager().unregisterListener(kickListener);
|
getProxy().getPluginManager().unregisterListener(kickListener);
|
||||||
kickListener = null;
|
kickListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
sectionManager.flush();
|
sectionManager.flush();
|
||||||
|
|
||||||
if (ConfigEntries.ASSIGN_TARGETS_ENABLED.get()) {
|
if (settings.getProperty(GeneralProperties.ASSIGN_TARGETS)) {
|
||||||
ServerAssignRegistry.getTable().clear();
|
ServerAssignRegistry.getTable().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package com.jaimemartz.playerbalancer.ping;
|
|||||||
|
|
||||||
import com.jaimemartz.playerbalancer.PlayerBalancer;
|
import com.jaimemartz.playerbalancer.PlayerBalancer;
|
||||||
import com.jaimemartz.playerbalancer.section.ServerSection;
|
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.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@ public class CheckerProperties implements SettingsHolder {
|
|||||||
|
|
||||||
public static final Property<Integer> TIMEOUT = newProperty("settings.server-check.timeout", 5000);
|
public static final Property<Integer> TIMEOUT = newProperty("settings.server-check.timeout", 5000);
|
||||||
|
|
||||||
public static final Property<Boolean> DEBUG = newProperty("settings.server-check.print-info", false);
|
public static final Property<List<String>> MARKER_DESCS = newListProperty("settings.server-check.marker-descs",
|
||||||
|
|
||||||
public static final Property<List<String>> MARKER_DESCS = newListProperty("settings.server-check.print-info",
|
|
||||||
"Sever is not accessible",
|
"Sever is not accessible",
|
||||||
"Gamemode has already started"
|
"Gamemode has already started"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static final Property<Boolean> DEBUG = newProperty("settings.server-check.print-info", false);
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,8 @@ public class ReconnectorProperties implements SettingsHolder {
|
|||||||
|
|
||||||
public static final Property<List<String>> IGNORED_SECTIONS = newListProperty("settings.reconnect-kick.ignored");
|
public static final Property<List<String>> IGNORED_SECTIONS = newListProperty("settings.reconnect-kick.ignored");
|
||||||
|
|
||||||
|
|
||||||
public static final Property<Boolean> RESTRICTED = newProperty("settings.reconnect-kick.restricted", true);
|
public static final Property<Boolean> RESTRICTED = newProperty("settings.reconnect-kick.restricted", true);
|
||||||
|
|
||||||
//todo is it really necessary?
|
|
||||||
public static final Property<Boolean> EXCLUDE_FROM = newProperty("settings.reconnect-kick.exclude-from", true);
|
|
||||||
|
|
||||||
public static final Property<Boolean> FORCE_PRINCIPAL = newProperty("settings.reconnect-kick.force-principal", false);
|
public static final Property<Boolean> FORCE_PRINCIPAL = newProperty("settings.reconnect-kick.force-principal", false);
|
||||||
|
|
||||||
public static final Property<MapBean> RULES = newBeanProperty(MapBean.class, "settings.reconnect-kick",
|
public static final Property<MapBean> RULES = newBeanProperty(MapBean.class, "settings.reconnect-kick",
|
||||||
|
Loading…
Reference in New Issue
Block a user