From ed6dc85bd0ed4c39ba167323a728f8732b0d525b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Mart=C3=ADnez=20Rinc=C3=B3n?= Date: Wed, 27 Sep 2017 18:34:43 +0200 Subject: [PATCH] Fixed the fallback principal option and renamed it to something better --- .../playerbalancer/commands/FallbackCommand.java | 4 +++- .../playerbalancer/commands/ManageCommand.java | 4 ++++ .../playerbalancer/listener/ServerKickListener.java | 4 +++- .../playerbalancer/ping/StatusManager.java | 3 ++- .../playerbalancer/settings/props/GeneralProps.java | 12 ------------ .../settings/props/features/BalancerProps.java | 11 +++++++++++ 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/jaimemartz/playerbalancer/commands/FallbackCommand.java b/src/main/java/com/jaimemartz/playerbalancer/commands/FallbackCommand.java index 6fa5509..967d9ff 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/commands/FallbackCommand.java +++ b/src/main/java/com/jaimemartz/playerbalancer/commands/FallbackCommand.java @@ -88,8 +88,10 @@ public class FallbackCommand extends Command { return target; } else { - if (plugin.getSettings().getGeneralProps().isFallbackPrincipal()) { + if (plugin.getSettings().getBalancerProps().isDefaultPrincipal()) { return plugin.getSectionManager().getPrincipal(); + } else { + MessageUtils.send(player, messages.getUnavailableServerMessage()); } } diff --git a/src/main/java/com/jaimemartz/playerbalancer/commands/ManageCommand.java b/src/main/java/com/jaimemartz/playerbalancer/commands/ManageCommand.java index 4b16541..84e5e9e 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/commands/ManageCommand.java +++ b/src/main/java/com/jaimemartz/playerbalancer/commands/ManageCommand.java @@ -190,6 +190,10 @@ public class ManageCommand extends Command { .color(ChatColor.WHITE) .append("\"") .color(ChatColor.AQUA) + .append("\nAddress: ") + .color(ChatColor.GRAY) + .append(server.getAddress().toString()) + .color(ChatColor.AQUA) .create())) .append(String.format(" (%d/%d) ", status.getOnline(), diff --git a/src/main/java/com/jaimemartz/playerbalancer/listener/ServerKickListener.java b/src/main/java/com/jaimemartz/playerbalancer/listener/ServerKickListener.java index bfe9aad..1215ae2 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/listener/ServerKickListener.java +++ b/src/main/java/com/jaimemartz/playerbalancer/listener/ServerKickListener.java @@ -124,8 +124,10 @@ public class ServerKickListener implements Listener { return target; } else { - if (plugin.getSettings().getGeneralProps().isFallbackPrincipal()) { + if (plugin.getSettings().getBalancerProps().isDefaultPrincipal()) { return plugin.getSectionManager().getPrincipal(); + } else { + MessageUtils.send(player, messages.getUnavailableServerMessage()); } } diff --git a/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java b/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java index b254cbb..82cb6eb 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java +++ b/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java @@ -28,7 +28,8 @@ public class StatusManager { stopped = false; tactic = plugin.getSettings().getServerCheckerProps().getTactic(); plugin.getLogger().info(String.format("Starting the ping task, the interval is %s", - plugin.getSettings().getServerCheckerProps().getInterval())); + plugin.getSettings().getServerCheckerProps().getInterval() + )); task = plugin.getProxy().getScheduler().schedule(plugin, () -> { storage.forEach((k, v) -> v.setOutdated(true)); diff --git a/src/main/java/com/jaimemartz/playerbalancer/settings/props/GeneralProps.java b/src/main/java/com/jaimemartz/playerbalancer/settings/props/GeneralProps.java index 281e2c8..69a51f1 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/settings/props/GeneralProps.java +++ b/src/main/java/com/jaimemartz/playerbalancer/settings/props/GeneralProps.java @@ -17,9 +17,6 @@ public class GeneralProps { @Setting(value = "redis-bungee") private boolean redisBungee; - @Setting(value = "fallback-principal") - private boolean fallbackPrincipal; - @Setting private String version; @@ -55,14 +52,6 @@ public class GeneralProps { this.redisBungee = redisBungee; } - public boolean isFallbackPrincipal() { - return fallbackPrincipal; - } - - public void setFallbackPrincipal(boolean fallbackPrincipal) { - this.fallbackPrincipal = fallbackPrincipal; - } - public String getVersion() { return version; } @@ -78,7 +67,6 @@ public class GeneralProps { ", silent=" + silent + ", autoReload=" + autoReload + ", redisBungee=" + redisBungee + - ", fallbackPrincipal=" + fallbackPrincipal + ", version='" + version + '\'' + '}'; } diff --git a/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/BalancerProps.java b/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/BalancerProps.java index a76e323..36adbe5 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/BalancerProps.java +++ b/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/BalancerProps.java @@ -12,6 +12,9 @@ public class BalancerProps { @Setting(value = "principal-section") private String principalSectionName; + @Setting(value = "default-principal") + private boolean defaultPrincipal; + @Setting(value = "dummy-sections") private List dummySectionNames; @@ -64,6 +67,14 @@ public class BalancerProps { this.showPlayers = showPlayers; } + public boolean isDefaultPrincipal() { + return defaultPrincipal; + } + + public void setDefaultPrincipal(boolean defaultPrincipal) { + this.defaultPrincipal = defaultPrincipal; + } + @Override public String toString() { return "BalancerProps{" +