mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-23 19:25:12 +01:00
Some little changes and fixes
This commit is contained in:
parent
34594eafaa
commit
5dd49b4caa
@ -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
|
||||
|
@ -48,7 +48,7 @@ public class FallbackCommand extends Command {
|
||||
}
|
||||
|
||||
ConnectionIntent.direct(plugin, player, server, (response, throwable) -> {
|
||||
//todo nothing to do?
|
||||
//TODO Handle this
|
||||
});
|
||||
|
||||
break;
|
||||
|
@ -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()))
|
||||
|
@ -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<Boolean> 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<Boolean> callback) {
|
||||
PlayerLocker.lock(player);
|
||||
player.connect(server, (result, throwable) -> {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<UUID> storage = Collections.synchronizedSet(new HashSet<UUID>());
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
));
|
||||
|
Loading…
Reference in New Issue
Block a user