mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-27 05:05:19 +01:00
Fixed errors with the section management command
This commit is contained in:
parent
330ed1c96a
commit
66f31500d8
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.jaimemartz</groupId>
|
<groupId>me.jaimemartz</groupId>
|
||||||
<artifactId>lobbybalancer</artifactId>
|
<artifactId>lobbybalancer</artifactId>
|
||||||
<version>2.0.9.1</version>
|
<version>2.0.9.2</version>
|
||||||
<name>LobbyBalancer</name>
|
<name>LobbyBalancer</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -73,7 +73,7 @@ public class ManageCommand extends Command {
|
|||||||
new Replacement("{name}", ChatColor.RED + section.getName()));
|
new Replacement("{name}", ChatColor.RED + section.getName()));
|
||||||
|
|
||||||
msgr.send("&7Principal: &b{status}",
|
msgr.send("&7Principal: &b{status}",
|
||||||
new Replacement("{status}", format(section.isPrincipal())));
|
new Replacement("{status}", section.isPrincipal() ? ChatColor.GREEN + "yes" : ChatColor.RED + "no"));
|
||||||
|
|
||||||
if (section.hasParent()) {
|
if (section.hasParent()) {
|
||||||
TextComponent message = new TextComponent("Parent: ");
|
TextComponent message = new TextComponent("Parent: ");
|
||||||
@ -92,34 +92,40 @@ public class ManageCommand extends Command {
|
|||||||
|
|
||||||
msgr.send("&7Provider: &b{name} &7({relation}&7)",
|
msgr.send("&7Provider: &b{name} &7({relation}&7)",
|
||||||
new Replacement("{name}", section.getProvider().name()),
|
new Replacement("{name}", section.getProvider().name()),
|
||||||
new Replacement("{relation}", section.isProviderInherited() ? "Inherited" : "Specified"));
|
new Replacement("{relation}", section.hasInheritedProvider() ? "Inherited" : "Specified"));
|
||||||
|
|
||||||
msgr.send("&7Dummy: &b{status}", new Replacement("{status}", format(section.isDummy())));
|
msgr.send("&7Dummy: &b{status}", new Replacement("{status}", section.isDummy() ? ChatColor.GREEN + "yes" : ChatColor.RED + "no"));
|
||||||
|
|
||||||
msgr.send("&7Section Server: &b{name}", new Replacement("{name}", section.hasServer() ? section.getServer().getName() : "None"));
|
msgr.send("&7Section Server: &b{name}", new Replacement("{name}", section.hasServer() ? section.getServer().getName() : "None"));
|
||||||
|
|
||||||
if (section.hasCommand()) {
|
if (section.hasCommand()) {
|
||||||
msgr.send("&7Section Command: &b{name}&7, Permission: &b{permission}&7, Aliases: &b{aliases}",
|
msgr.send("&7Section Command: &b{name}&7, Permission: &b{permission}&7, Aliases: &b{aliases}",
|
||||||
new Replacement("{name}", section.getCommand().getName()),
|
new Replacement("{name}", section.getCommand().getName()),
|
||||||
new Replacement("{permission}", section.getCommand().getPermission().equals("") ? "none" : section.getCommand().getPermission()),
|
new Replacement("{permission}", section.getCommand().getPermission().equals("") ? "None" : section.getCommand().getPermission()),
|
||||||
new Replacement("{aliases}", StringCombiner.combine(section.getCommand().getAliases(), ", ")));
|
new Replacement("{aliases}", section.getCommand().getAliases().length == 0 ? "None" : StringCombiner.combine(section.getCommand().getAliases(), ", ")));
|
||||||
} else {
|
} else {
|
||||||
msgr.send("&7Section Command: &bNone");
|
msgr.send("&7Section Command: &bNone");
|
||||||
}
|
}
|
||||||
|
|
||||||
msgr.send("&7Valid: &b{status}",
|
msgr.send("&7Valid: &b{status}",
|
||||||
new Replacement("{status}", format(section.isValid())));
|
new Replacement("{status}", section.isValid() ? ChatColor.GREEN + "yes" : ChatColor.RED + "no"));
|
||||||
|
|
||||||
|
|
||||||
|
if (!section.getServers().isEmpty()) {
|
||||||
|
msgr.send("&7Section Servers: ");
|
||||||
|
section.getServers().forEach(server -> {
|
||||||
|
ServerStatus status = plugin.getPingManager().getStatus(server);
|
||||||
|
msgr.send("&7Server &b{name} &c({connected}/{maximum}) &7({status}&7)",
|
||||||
|
new Replacement("{name}", server.getName()),
|
||||||
|
new Replacement("{connected}", String.valueOf(status.getOnlinePlayers())),
|
||||||
|
new Replacement("{maximum}", String.valueOf(status.getMaximumPlayers())),
|
||||||
|
new Replacement("{status}", status.isAccessible() ? ChatColor.GREEN + "Accessible" : ChatColor.RED + "Inaccessible")
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
msgr.send("&7Section Servers: &bNone");
|
||||||
|
}
|
||||||
|
|
||||||
msgr.send("&7Section Servers: ");
|
|
||||||
section.getServers().forEach(server -> {
|
|
||||||
ServerStatus status = plugin.getPingManager().getStatus(server);
|
|
||||||
msgr.send("&7Server &b{name} &c({connected}/{maximum}) &7({status}&7)",
|
|
||||||
new Replacement("{name}", server.getName()),
|
|
||||||
new Replacement("{connected}", String.valueOf(status.getOnlinePlayers())),
|
|
||||||
new Replacement("{maximum}", String.valueOf(status.getMaximumPlayers())),
|
|
||||||
new Replacement("{status}", status.isAccessible() ? ChatColor.GREEN + "Accessible" : ChatColor.RED + "Inaccessible")
|
|
||||||
);
|
|
||||||
});
|
|
||||||
msgr.send("&7&m-----------------------------------------------------");
|
msgr.send("&7&m-----------------------------------------------------");
|
||||||
} else {
|
} else {
|
||||||
msgr.send(ConfigEntries.UNKNOWN_SECTION_MESSAGE.get());
|
msgr.send(ConfigEntries.UNKNOWN_SECTION_MESSAGE.get());
|
||||||
@ -136,22 +142,29 @@ public class ManageCommand extends Command {
|
|||||||
TextComponent message = new TextComponent(String.format("There are %s configured sections:\n", keys.size()));
|
TextComponent message = new TextComponent(String.format("There are %s configured sections:\n", keys.size()));
|
||||||
message.setColor(ChatColor.GRAY);
|
message.setColor(ChatColor.GRAY);
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
if (iterator.hasNext()) {
|
||||||
String name = iterator.next();
|
while (iterator.hasNext()) {
|
||||||
TextComponent extra = new TextComponent(name);
|
String name = iterator.next();
|
||||||
extra.setColor(ChatColor.GREEN);
|
TextComponent extra = new TextComponent(name);
|
||||||
extra.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/section info %s", name)));
|
extra.setColor(ChatColor.GREEN);
|
||||||
extra.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click me for info").color(ChatColor.RED).create()));
|
extra.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/section info %s", name)));
|
||||||
|
extra.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click me for info").color(ChatColor.RED).create()));
|
||||||
|
|
||||||
if (iterator.hasNext()) {
|
if (iterator.hasNext()) {
|
||||||
TextComponent sep = new TextComponent(", ");
|
TextComponent sep = new TextComponent(", ");
|
||||||
sep.setColor(ChatColor.GRAY);
|
sep.setColor(ChatColor.GRAY);
|
||||||
extra.addExtra(sep);
|
extra.addExtra(sep);
|
||||||
|
}
|
||||||
|
|
||||||
|
message.addExtra(extra);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
TextComponent extra = new TextComponent("There are no sections to list");
|
||||||
|
extra.setColor(ChatColor.RED);
|
||||||
message.addExtra(extra);
|
message.addExtra(extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -179,8 +192,4 @@ public class ManageCommand extends Command {
|
|||||||
"&7&m-----------------------------------------------------"
|
"&7&m-----------------------------------------------------"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String format(boolean reference) {
|
|
||||||
return reference ? ChatColor.GREEN + "yes" : ChatColor.RED + "no";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ public class ServerSection {
|
|||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isProviderInherited() {
|
public boolean hasInheritedProvider() {
|
||||||
return inherited;
|
return inherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ settings:
|
|||||||
# Comment a message to disable it
|
# Comment a message to disable it
|
||||||
messages:
|
messages:
|
||||||
connecting: '&aConnecting to {server}'
|
connecting: '&aConnecting to {server}'
|
||||||
failure: '&cCould not find a server to connect to'
|
failure: '&cCould not find a server to get connected'
|
||||||
unavailable: '&cThis command cannot be executed on this server'
|
unavailable: '&cThis command cannot be executed on this server'
|
||||||
unknown: '&cCould not find a section with that name'
|
unknown: '&cCould not find a section with that name'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user