diff --git a/README.md b/README.md index a8a2d0d..693cca4 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ * Build with maven ### Things to do: -- [ ] Add support for wildcards, contains, equalsIgnoreCase and regex at the same time - [ ] Create a spigot addon that adds connector signs and placeholders - [ ] Separate the types of connections in classes instead of being in ConnectionIntent - [ ] Make the plugin API be not so dependent on a instance of PlayerBalancer diff --git a/src/main/java/com/jaimemartz/playerbalancer/commands/FallbackCommand.java b/src/main/java/com/jaimemartz/playerbalancer/commands/FallbackCommand.java index e5359a5..99354b8 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/commands/FallbackCommand.java +++ b/src/main/java/com/jaimemartz/playerbalancer/commands/FallbackCommand.java @@ -48,7 +48,7 @@ public class FallbackCommand extends Command { } ConnectionIntent.direct(plugin, player, server, (response, throwable) -> { - //todo nothing to do? + //TODO Handle this }); break; diff --git a/src/main/java/com/jaimemartz/playerbalancer/commands/ManageCommand.java b/src/main/java/com/jaimemartz/playerbalancer/commands/ManageCommand.java index 921a2d5..9b06409 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/commands/ManageCommand.java +++ b/src/main/java/com/jaimemartz/playerbalancer/commands/ManageCommand.java @@ -146,16 +146,15 @@ public class ManageCommand extends Command { .color(ChatColor.GRAY) .append(section.getCommand().getName()) .color(ChatColor.AQUA) - .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - new ComponentBuilder("Permission: ") - .color(ChatColor.GRAY) - .append(section.getCommand().getPermission().equals("") ? "None" : section.getCommand().getPermission()) - .color(ChatColor.AQUA) - .append("\nAliases: ") - .color(ChatColor.GRAY) - .append(Arrays.toString(section.getCommand().getAliases())) - .color(ChatColor.AQUA) - .create()) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Permission: ") + .color(ChatColor.GRAY) + .append(section.getCommand().getPermission().equals("") ? "None" : section.getCommand().getPermission()) + .color(ChatColor.AQUA) + .append("\nAliases: ") + .color(ChatColor.GRAY) + .append(Arrays.toString(section.getCommand().getAliases())) + .color(ChatColor.AQUA) + .create()) ).create() ); } else { @@ -179,20 +178,19 @@ public class ManageCommand extends Command { .color(ChatColor.GRAY) .append(server.getName()) .color(ChatColor.AQUA) - .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - new ComponentBuilder("Accessible: ") - .color(ChatColor.GRAY) - .append(status.isAccessible(plugin, null) ? "yes" : "no") - .color(status.isAccessible(plugin, null) ? ChatColor.GREEN : ChatColor.RED) - .append("\nDescription: ") - .color(ChatColor.GRAY) - .append("\"") - .color(ChatColor.AQUA) - .append(status.getDescription()) - .color(ChatColor.WHITE) - .append("\"") - .color(ChatColor.AQUA) - .create())) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Accessible: ") + .color(ChatColor.GRAY) + .append(status.isAccessible(plugin) ? "yes" : "no") + .color(status.isAccessible(plugin) ? ChatColor.GREEN : ChatColor.RED) + .append("\nDescription: ") + .color(ChatColor.GRAY) + .append("\"") + .color(ChatColor.AQUA) + .append(status.getDescription()) + .color(ChatColor.WHITE) + .append("\"") + .color(ChatColor.AQUA) + .create())) .append(String.format(" (%d/%d) ", status.getOnline(), status.getMaximum())) diff --git a/src/main/java/com/jaimemartz/playerbalancer/connection/ConnectionIntent.java b/src/main/java/com/jaimemartz/playerbalancer/connection/ConnectionIntent.java index 8bb37e8..ee0ee04 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/connection/ConnectionIntent.java +++ b/src/main/java/com/jaimemartz/playerbalancer/connection/ConnectionIntent.java @@ -73,7 +73,7 @@ public abstract class ConnectionIntent { if (ServerAssignRegistry.hasAssignedServer(player, section)) { ServerInfo target = ServerAssignRegistry.getAssignedServer(player, section); ServerStatus status = plugin.getStatusManager().getStatus(target); - if (status.isAccessible(plugin, player)) { + if (status.isAccessible(plugin)) { return target; } else { ServerAssignRegistry.revokeTarget(player, section); @@ -89,7 +89,7 @@ public abstract class ConnectionIntent { if (target == null) continue; ServerStatus status = plugin.getStatusManager().getStatus(target); - if (status.isAccessible(plugin, player)) { + if (status.isAccessible(plugin)) { return target; } else { servers.remove(target); @@ -101,7 +101,7 @@ public abstract class ConnectionIntent { public abstract void connect(ServerInfo server, Callback callback); - //todo create this as a type + //TODO Create this as a type public static void simple(PlayerBalancer plugin, ProxiedPlayer player, ServerSection section) { new ConnectionIntent(plugin, player, section) { @Override @@ -111,7 +111,7 @@ public abstract class ConnectionIntent { }; } - //todo create this as a type + //TODO Create this as a type public static void direct(PlayerBalancer plugin, ProxiedPlayer player, ServerInfo server, Callback callback) { PlayerLocker.lock(player); player.connect(server, (result, throwable) -> { diff --git a/src/main/java/com/jaimemartz/playerbalancer/listener/ServerKickListener.java b/src/main/java/com/jaimemartz/playerbalancer/listener/ServerKickListener.java index 326bd56..bfe9aad 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/listener/ServerKickListener.java +++ b/src/main/java/com/jaimemartz/playerbalancer/listener/ServerKickListener.java @@ -40,7 +40,7 @@ public class ServerKickListener implements Listener { String reason = TextComponent.toPlainText(event.getKickReasonComponent()); for (String string : props.getReasons()) { - if (reason.matches(string) || reason.contains(string)) { //todo improve this + if (reason.matches(string)) { matches = true; break; } diff --git a/src/main/java/com/jaimemartz/playerbalancer/manager/PlayerLocker.java b/src/main/java/com/jaimemartz/playerbalancer/manager/PlayerLocker.java index 8342d1e..37041e9 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/manager/PlayerLocker.java +++ b/src/main/java/com/jaimemartz/playerbalancer/manager/PlayerLocker.java @@ -7,7 +7,7 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; -//TODO improve this? maybe? +//TODO I don't like it, improve it public class PlayerLocker { private static final Set storage = Collections.synchronizedSet(new HashSet()); diff --git a/src/main/java/com/jaimemartz/playerbalancer/ping/ServerStatus.java b/src/main/java/com/jaimemartz/playerbalancer/ping/ServerStatus.java index 60b4d8d..b8e7085 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/ping/ServerStatus.java +++ b/src/main/java/com/jaimemartz/playerbalancer/ping/ServerStatus.java @@ -2,7 +2,6 @@ package com.jaimemartz.playerbalancer.ping; import com.jaimemartz.playerbalancer.PlayerBalancer; import net.md_5.bungee.api.config.ServerInfo; -import net.md_5.bungee.api.connection.ProxiedPlayer; public final class ServerStatus { private final String description; @@ -23,14 +22,13 @@ public final class ServerStatus { this.maximum = maximum; } - //TODO improve this (set from the pinger if accessible or not) maybe? - public boolean isAccessible(PlayerBalancer plugin, ProxiedPlayer player) { + public boolean isAccessible(PlayerBalancer plugin) { if (maximum == 0) { return false; } for (String pattern : plugin.getSettings().getServerCheckerProps().getMarkerDescs()) { - if (description.matches(pattern) || description.contains(pattern)) { + if (description.matches(pattern)) { return false; } } diff --git a/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java b/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java index 0f8f4a8..b254cbb 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java +++ b/src/main/java/com/jaimemartz/playerbalancer/ping/StatusManager.java @@ -63,8 +63,9 @@ public class StatusManager { } if (plugin.getSettings().getServerCheckerProps().isDebug()) { - plugin.getLogger().info(String.format("Updated server %s, status: [Description: \"%s\", Online Players: %s, Maximum Players: %s, Accessible: %s]", - server.getName(), status.getDescription(), status.getOnline(), status.getMaximum(), status.isAccessible(plugin, null) + plugin.getLogger().info(String.format( + "Updated server %s, status: [Description: \"%s\", Online Players: %s, Maximum Players: %s, Accessible: %s]", + server.getName(), status.getDescription(), status.getOnline(), status.getMaximum(), status.isAccessible(plugin) )); } diff --git a/src/main/java/com/jaimemartz/playerbalancer/section/SectionManager.java b/src/main/java/com/jaimemartz/playerbalancer/section/SectionManager.java index c626da0..5a68dc9 100644 --- a/src/main/java/com/jaimemartz/playerbalancer/section/SectionManager.java +++ b/src/main/java/com/jaimemartz/playerbalancer/section/SectionManager.java @@ -74,10 +74,18 @@ public class SectionManager { } ServerSection other = servers.get(server); - throw new IllegalArgumentException(String.format("The server \"%s\" is already in the section \"%s\"", server.getName(), other.getName())); + throw new IllegalArgumentException(String.format( + "The server \"%s\" is already in the section \"%s\"", + server.getName(), + other.getName() + )); } - plugin.getLogger().info(String.format("Registering server \"%s\" to section \"%s\"", server.getName(), section.getName())); + plugin.getLogger().info(String.format("Registering server \"%s\" to section \"%s\"", + server.getName(), + section.getName() + )); + servers.put(server, section); } @@ -248,7 +256,7 @@ public class SectionManager { }); plugin.getLogger().info(String.format("Recognized %s server(s) out of %s in the section \"%s\"", - servers.size(), + results.size(), section.getProps().getServerEntries(), section.getName() ));