Skip to content

Commit 5dd49b4

Browse files
committed
Some little changes and fixes
1 parent 34594ea commit 5dd49b4

File tree

9 files changed

+45
-41
lines changed

9 files changed

+45
-41
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* Build with maven
1010

1111
### Things to do:
12-
- [ ] Add support for wildcards, contains, equalsIgnoreCase and regex at the same time
1312
- [ ] Create a spigot addon that adds connector signs and placeholders
1413
- [ ] Separate the types of connections in classes instead of being in ConnectionIntent
1514
- [ ] Make the plugin API be not so dependent on a instance of PlayerBalancer

src/main/java/com/jaimemartz/playerbalancer/commands/FallbackCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void execute(CommandSender sender, String[] args) {
4848
}
4949

5050
ConnectionIntent.direct(plugin, player, server, (response, throwable) -> {
51-
//todo nothing to do?
51+
//TODO Handle this
5252
});
5353

5454
break;

src/main/java/com/jaimemartz/playerbalancer/commands/ManageCommand.java

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,15 @@ public void execute(CommandSender sender, String[] args) {
146146
.color(ChatColor.GRAY)
147147
.append(section.getCommand().getName())
148148
.color(ChatColor.AQUA)
149-
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
150-
new ComponentBuilder("Permission: ")
151-
.color(ChatColor.GRAY)
152-
.append(section.getCommand().getPermission().equals("") ? "None" : section.getCommand().getPermission())
153-
.color(ChatColor.AQUA)
154-
.append("\nAliases: ")
155-
.color(ChatColor.GRAY)
156-
.append(Arrays.toString(section.getCommand().getAliases()))
157-
.color(ChatColor.AQUA)
158-
.create())
149+
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Permission: ")
150+
.color(ChatColor.GRAY)
151+
.append(section.getCommand().getPermission().equals("") ? "None" : section.getCommand().getPermission())
152+
.color(ChatColor.AQUA)
153+
.append("\nAliases: ")
154+
.color(ChatColor.GRAY)
155+
.append(Arrays.toString(section.getCommand().getAliases()))
156+
.color(ChatColor.AQUA)
157+
.create())
159158
).create()
160159
);
161160
} else {
@@ -179,20 +178,19 @@ public void execute(CommandSender sender, String[] args) {
179178
.color(ChatColor.GRAY)
180179
.append(server.getName())
181180
.color(ChatColor.AQUA)
182-
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
183-
new ComponentBuilder("Accessible: ")
184-
.color(ChatColor.GRAY)
185-
.append(status.isAccessible(plugin, null) ? "yes" : "no")
186-
.color(status.isAccessible(plugin, null) ? ChatColor.GREEN : ChatColor.RED)
187-
.append("\nDescription: ")
188-
.color(ChatColor.GRAY)
189-
.append("\"")
190-
.color(ChatColor.AQUA)
191-
.append(status.getDescription())
192-
.color(ChatColor.WHITE)
193-
.append("\"")
194-
.color(ChatColor.AQUA)
195-
.create()))
181+
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Accessible: ")
182+
.color(ChatColor.GRAY)
183+
.append(status.isAccessible(plugin) ? "yes" : "no")
184+
.color(status.isAccessible(plugin) ? ChatColor.GREEN : ChatColor.RED)
185+
.append("\nDescription: ")
186+
.color(ChatColor.GRAY)
187+
.append("\"")
188+
.color(ChatColor.AQUA)
189+
.append(status.getDescription())
190+
.color(ChatColor.WHITE)
191+
.append("\"")
192+
.color(ChatColor.AQUA)
193+
.create()))
196194
.append(String.format(" (%d/%d) ",
197195
status.getOnline(),
198196
status.getMaximum()))

src/main/java/com/jaimemartz/playerbalancer/connection/ConnectionIntent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private ServerInfo fetchServer(PlayerBalancer plugin, ProxiedPlayer player, Serv
7373
if (ServerAssignRegistry.hasAssignedServer(player, section)) {
7474
ServerInfo target = ServerAssignRegistry.getAssignedServer(player, section);
7575
ServerStatus status = plugin.getStatusManager().getStatus(target);
76-
if (status.isAccessible(plugin, player)) {
76+
if (status.isAccessible(plugin)) {
7777
return target;
7878
} else {
7979
ServerAssignRegistry.revokeTarget(player, section);
@@ -89,7 +89,7 @@ private ServerInfo fetchServer(PlayerBalancer plugin, ProxiedPlayer player, Serv
8989
if (target == null) continue;
9090

9191
ServerStatus status = plugin.getStatusManager().getStatus(target);
92-
if (status.isAccessible(plugin, player)) {
92+
if (status.isAccessible(plugin)) {
9393
return target;
9494
} else {
9595
servers.remove(target);
@@ -101,7 +101,7 @@ private ServerInfo fetchServer(PlayerBalancer plugin, ProxiedPlayer player, Serv
101101

102102
public abstract void connect(ServerInfo server, Callback<Boolean> callback);
103103

104-
//todo create this as a type
104+
//TODO Create this as a type
105105
public static void simple(PlayerBalancer plugin, ProxiedPlayer player, ServerSection section) {
106106
new ConnectionIntent(plugin, player, section) {
107107
@Override
@@ -111,7 +111,7 @@ public void connect(ServerInfo server, Callback<Boolean> callback) {
111111
};
112112
}
113113

114-
//todo create this as a type
114+
//TODO Create this as a type
115115
public static void direct(PlayerBalancer plugin, ProxiedPlayer player, ServerInfo server, Callback<Boolean> callback) {
116116
PlayerLocker.lock(player);
117117
player.connect(server, (result, throwable) -> {

src/main/java/com/jaimemartz/playerbalancer/listener/ServerKickListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void onKick(ServerKickEvent event) {
4040
String reason = TextComponent.toPlainText(event.getKickReasonComponent());
4141

4242
for (String string : props.getReasons()) {
43-
if (reason.matches(string) || reason.contains(string)) { //todo improve this
43+
if (reason.matches(string)) {
4444
matches = true;
4545
break;
4646
}

src/main/java/com/jaimemartz/playerbalancer/manager/PlayerLocker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.util.Set;
88
import java.util.UUID;
99

10-
//TODO improve this? maybe?
10+
//TODO I don't like it, improve it
1111
public class PlayerLocker {
1212
private static final Set<UUID> storage = Collections.synchronizedSet(new HashSet<UUID>());
1313

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.jaimemartz.playerbalancer.PlayerBalancer;
44
import net.md_5.bungee.api.config.ServerInfo;
5-
import net.md_5.bungee.api.connection.ProxiedPlayer;
65

76
public final class ServerStatus {
87
private final String description;
@@ -23,14 +22,13 @@ public ServerStatus(String description, int online, int maximum) {
2322
this.maximum = maximum;
2423
}
2524

26-
//TODO improve this (set from the pinger if accessible or not) maybe?
27-
public boolean isAccessible(PlayerBalancer plugin, ProxiedPlayer player) {
25+
public boolean isAccessible(PlayerBalancer plugin) {
2826
if (maximum == 0) {
2927
return false;
3028
}
3129

3230
for (String pattern : plugin.getSettings().getServerCheckerProps().getMarkerDescs()) {
33-
if (description.matches(pattern) || description.contains(pattern)) {
31+
if (description.matches(pattern)) {
3432
return false;
3533
}
3634
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ private void update(ServerInfo server) {
6363
}
6464

6565
if (plugin.getSettings().getServerCheckerProps().isDebug()) {
66-
plugin.getLogger().info(String.format("Updated server %s, status: [Description: \"%s\", Online Players: %s, Maximum Players: %s, Accessible: %s]",
67-
server.getName(), status.getDescription(), status.getOnline(), status.getMaximum(), status.isAccessible(plugin, null)
66+
plugin.getLogger().info(String.format(
67+
"Updated server %s, status: [Description: \"%s\", Online Players: %s, Maximum Players: %s, Accessible: %s]",
68+
server.getName(), status.getDescription(), status.getOnline(), status.getMaximum(), status.isAccessible(plugin)
6869
));
6970
}
7071

src/main/java/com/jaimemartz/playerbalancer/section/SectionManager.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,18 @@ public void register(ServerInfo server, ServerSection section) {
7474
}
7575

7676
ServerSection other = servers.get(server);
77-
throw new IllegalArgumentException(String.format("The server \"%s\" is already in the section \"%s\"", server.getName(), other.getName()));
77+
throw new IllegalArgumentException(String.format(
78+
"The server \"%s\" is already in the section \"%s\"",
79+
server.getName(),
80+
other.getName()
81+
));
7882
}
7983

80-
plugin.getLogger().info(String.format("Registering server \"%s\" to section \"%s\"", server.getName(), section.getName()));
84+
plugin.getLogger().info(String.format("Registering server \"%s\" to section \"%s\"",
85+
server.getName(),
86+
section.getName()
87+
));
88+
8189
servers.put(server, section);
8290

8391
}
@@ -248,7 +256,7 @@ public Set<ServerInfo> calculateServers(ServerSection section) {
248256
});
249257

250258
plugin.getLogger().info(String.format("Recognized %s server(s) out of %s in the section \"%s\"",
251-
servers.size(),
259+
results.size(),
252260
section.getProps().getServerEntries(),
253261
section.getName()
254262
));

0 commit comments

Comments
 (0)