Skip to content

Commit 6205a61

Browse files
committed
Progress on migrating to properties
1 parent 65930a7 commit 6205a61

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
import com.jaimemartz.playerbalancer.section.SectionManager;
1414
import com.jaimemartz.playerbalancer.settings.Settings;
1515
import com.jaimemartz.playerbalancer.settings.SettingsProvider;
16+
import com.jaimemartz.playerbalancer.settings.types.CheckerProperties;
17+
import com.jaimemartz.playerbalancer.settings.types.CommandProperties;
18+
import com.jaimemartz.playerbalancer.settings.types.GeneralProperties;
19+
import com.jaimemartz.playerbalancer.settings.types.ReconnectorProperties;
1620
import lombok.Getter;
1721
import net.md_5.bungee.api.ProxyServer;
1822
import net.md_5.bungee.api.plugin.Command;
@@ -63,12 +67,12 @@ private boolean enable() {
6367
mainCommand = new MainCommand(this);
6468
getProxy().getPluginManager().registerCommand(this, mainCommand);
6569

66-
if (ConfigEntries.PLUGIN_ENABLED.get()) {
67-
if (ConfigEntries.SILENT_STARTUP.get()) {
70+
if (settings.getProperty(GeneralProperties.ENABLED)) {
71+
if (settings.getProperty(GeneralProperties.SILENT)) {
6872
getLogger().setLevel(Level.WARNING);
6973
}
7074

71-
if (ConfigEntries.AUTO_RELOAD_ENABLED.get()) {
75+
if (settings.getProperty(GeneralProperties.AUTO_RELOAD)) {
7276
reloadListener = new ProxyReloadListener(this);
7377
getProxy().getPluginManager().registerListener(this, reloadListener);
7478
}
@@ -85,11 +89,11 @@ private boolean enable() {
8589
sectionManager.load();
8690

8791
statusManager = new StatusManager();
88-
if (ConfigEntries.SERVER_CHECK_ENABLED.get()) {
92+
if (settings.getProperty(CheckerProperties.ENABLED)) {
8993
statusManager.start(this);
9094
}
9195

92-
if (ConfigEntries.FALLBACK_COMMAND_ENABLED.get()) {
96+
if (settings.getProperty(CommandProperties.ENABLED)) {
9397
fallbackCommand = new FallbackCommand(this);
9498
getProxy().getPluginManager().registerCommand(this, fallbackCommand);
9599
}
@@ -109,7 +113,7 @@ private boolean enable() {
109113

110114
Stream.of(PasteHelper.values()).forEach(a -> a.setUrl(null));
111115

112-
if (ConfigEntries.RECONNECT_KICK_ENABLED.get()) {
116+
if (settings.getProperty(ReconnectorProperties.ENABLED)) {
113117
kickListener = new ServerKickListener(this);
114118
getProxy().getPluginManager().registerListener(this, kickListener);
115119
}
@@ -139,20 +143,20 @@ private void disable() {
139143
getProxy().getPluginManager().unregisterCommand(mainCommand);
140144
mainCommand = null;
141145

142-
if (ConfigEntries.PLUGIN_ENABLED.get()) {
146+
if (settings.getProperty(GeneralProperties.ENABLED)) {
143147
//Do not try to do anything if the plugin has not loaded correctly
144148
if (isFailed()) return;
145149

146-
if (ConfigEntries.AUTO_RELOAD_ENABLED.get()) {
150+
if (settings.getProperty(GeneralProperties.AUTO_RELOAD)) {
147151
getProxy().getPluginManager().unregisterListener(reloadListener);
148152
reloadListener = null;
149153
}
150154

151-
if (ConfigEntries.SERVER_CHECK_ENABLED.get()) {
155+
if (settings.getProperty(CheckerProperties.ENABLED)) {
152156
statusManager.stop();
153157
}
154158

155-
if (ConfigEntries.FALLBACK_COMMAND_ENABLED.get()) {
159+
if (settings.getProperty(CommandProperties.ENABLED)) {
156160
getProxy().getPluginManager().unregisterCommand(fallbackCommand);
157161
fallbackCommand = null;
158162
}
@@ -166,14 +170,14 @@ private void disable() {
166170
getProxy().getPluginManager().unregisterCommand(manageCommand);
167171
manageCommand = null;
168172

169-
if (ConfigEntries.RECONNECT_KICK_ENABLED.get()) {
173+
if (settings.getProperty(ReconnectorProperties.ENABLED)) {
170174
getProxy().getPluginManager().unregisterListener(kickListener);
171175
kickListener = null;
172176
}
173177

174178
sectionManager.flush();
175179

176-
if (ConfigEntries.ASSIGN_TARGETS_ENABLED.get()) {
180+
if (settings.getProperty(GeneralProperties.ASSIGN_TARGETS)) {
177181
ServerAssignRegistry.getTable().clear();
178182
}
179183
}

src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.jaimemartz.playerbalancer.PlayerBalancer;
44
import com.jaimemartz.playerbalancer.section.ServerSection;
5-
import com.jaimemartz.playerbalancer.settings.ConfigEntries;
65
import net.md_5.bungee.api.config.ServerInfo;
76
import net.md_5.bungee.api.scheduler.ScheduledTask;
87

src/main/java/com/jaimemartz/playerbalancer/settings/types/CheckerProperties.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public class CheckerProperties implements SettingsHolder {
2020

2121
public static final Property<Integer> TIMEOUT = newProperty("settings.server-check.timeout", 5000);
2222

23-
public static final Property<Boolean> DEBUG = newProperty("settings.server-check.print-info", false);
24-
25-
public static final Property<List<String>> MARKER_DESCS = newListProperty("settings.server-check.print-info",
23+
public static final Property<List<String>> MARKER_DESCS = newListProperty("settings.server-check.marker-descs",
2624
"Sever is not accessible",
2725
"Gamemode has already started"
2826
);
27+
28+
public static final Property<Boolean> DEBUG = newProperty("settings.server-check.print-info", false);
2929
}

src/main/java/com/jaimemartz/playerbalancer/settings/types/ReconnectorProperties.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@ public class ReconnectorProperties implements SettingsHolder {
1818

1919
public static final Property<List<String>> IGNORED_SECTIONS = newListProperty("settings.reconnect-kick.ignored");
2020

21-
2221
public static final Property<Boolean> RESTRICTED = newProperty("settings.reconnect-kick.restricted", true);
2322

24-
//todo is it really necessary?
25-
public static final Property<Boolean> EXCLUDE_FROM = newProperty("settings.reconnect-kick.exclude-from", true);
26-
2723
public static final Property<Boolean> FORCE_PRINCIPAL = newProperty("settings.reconnect-kick.force-principal", false);
2824

2925
public static final Property<MapBean> RULES = newBeanProperty(MapBean.class, "settings.reconnect-kick",

0 commit comments

Comments
 (0)