Further define proxy status colors

The proxies section of the list command now functions like the rest. You can hover over proxies in-game to get more status information on them.

The colors shown are as follows:
Green (Optimal): Proxy is connected to both Redis and SubData
Blue (Available): Proxy is connected to SubData only
White (External): Proxy is connected to Redis only
Red (Disabled): Proxy is offline
This commit is contained in:
ME1312 2018-08-05 22:07:18 -04:00
parent a7e9185ce4
commit 38eec66a4b
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
13 changed files with 190 additions and 28 deletions

View File

@ -83,6 +83,17 @@ public class Proxy implements ClientHandler, ExtraDataHandler {
} }
} }
/**
* Test if the proxy is connected to RedisBungee's server
*
* @return Redis Status
*/
@SuppressWarnings({"deprecation", "unchecked"})
public boolean isRedis() {
SubPlugin plugin = SubAPI.getInstance().getInternals();
return plugin.redis && Util.getDespiteException(() -> plugin.redis("getPlayersOnProxy", new NamedContainer<>(String.class, getName())) != null, false);
}
/** /**
* Get the players on this proxy (via RedisBungee) * Get the players on this proxy (via RedisBungee)
* *
@ -152,6 +163,7 @@ public class Proxy implements ClientHandler, ExtraDataHandler {
players.set(player.get().toString(), pinfo); players.set(player.get().toString(), pinfo);
} }
info.set("players", players); info.set("players", players);
info.set("redis", isRedis());
if (getSubData() != null) info.set("subdata", getSubData().getAddress().toString()); if (getSubData() != null) info.set("subdata", getSubData().getAddress().toString());
info.set("signature", signature); info.set("signature", signature);
info.set("extra", getExtra()); info.set("extra", getExtra());

View File

@ -80,6 +80,10 @@ Lang:
'Interface.Generic.Downloading.Title-Color-Alt': '&3' 'Interface.Generic.Downloading.Title-Color-Alt': '&3'
'Interface.Generic.Downloading.Response': '&eWaiting for response' 'Interface.Generic.Downloading.Response': '&eWaiting for response'
'Interface.Generic.Invalid-Permission': '&4You need &n$str$' 'Interface.Generic.Invalid-Permission': '&4You need &n$str$'
'Interface.Proxy-Menu.Proxy-Master': '&8Master Proxy'
'Interface.Proxy-Menu.Proxy-SubData': '&9SubData Only'
'Interface.Proxy-Menu.Proxy-Redis': '&7Redis Only'
'Interface.Proxy-Menu.Proxy-Disconnected': '&4Disconnected'
'Interface.Host-Menu.Title': 'Host Menu' 'Interface.Host-Menu.Title': 'Host Menu'
'Interface.Host-Menu.Host-Disabled': '&4Disabled' 'Interface.Host-Menu.Host-Disabled': '&4Disabled'
'Interface.Host-Menu.Host-Server-Count': '&9$int$ Server(s)' 'Interface.Host-Menu.Host-Server-Count': '&9$int$ Server(s)'

View File

@ -60,6 +60,7 @@ public class PacketDownloadServerList implements PacketIn, PacketOut {
proxies.set(proxy.getName(), new YAMLSection(new Gson().fromJson(proxy.toString(), Map.class))); proxies.set(proxy.getName(), new YAMLSection(new Gson().fromJson(proxy.toString(), Map.class)));
} }
data.set("proxies", proxies); data.set("proxies", proxies);
if (plugin.redis) data.set("master-proxy", Util.getDespiteException(() -> plugin.redis("getServerId"), null));
YAMLSection exServers = new YAMLSection(); YAMLSection exServers = new YAMLSection();
for (Server server : plugin.exServers.values()) { for (Server server : plugin.exServers.values()) {

View File

@ -213,7 +213,17 @@ public final class SubCommand extends CommandX {
sender.sendMessage("SubServers > Proxy List:"); sender.sendMessage("SubServers > Proxy List:");
message = " (master)"; message = " (master)";
for (Proxy proxy : plugin.api.getProxies().values()) { for (Proxy proxy : plugin.api.getProxies().values()) {
message += div + ((proxy.getSubData() != null)?ChatColor.AQUA:ChatColor.WHITE) + proxy.getDisplayName() + ((proxy.getName().equals(proxy.getDisplayName()))?"":" ("+proxy.getName()+')'); message += div;
if (proxy.getSubData() != null && proxy.isRedis()) {
message += ChatColor.GREEN;
} else if (proxy.getSubData() != null) {
message += ChatColor.AQUA;
} else if (proxy.isRedis()) {
message += ChatColor.WHITE;
} else {
message += ChatColor.RED;
}
message += proxy.getDisplayName() + ((proxy.getName().equals(proxy.getDisplayName()))?"":" ("+proxy.getName()+')');
} }
sender.sendMessage(message); sender.sendMessage(message);
} }

View File

@ -289,25 +289,68 @@ public class BungeeChat {
else ((Player) sender).spigot().sendMessage(msg); else ((Player) sender).spigot().sendMessage(msg);
if (data.getSection("proxies").getKeys().size() > 0) { if (data.getSection("proxies").getKeys().size() > 0) {
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Proxy-Header")); sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Proxy-Header"));
msg = new TextComponent(" (master)"); msg = new TextComponent(" ");
msg.setColor(ChatColor.GRAY);
for (String proxy : data.getSection("proxies").getKeys()) {
List<TextComponent> hoverm = new LinkedList<TextComponent>(); List<TextComponent> hoverm = new LinkedList<TextComponent>();
TextComponent message = new TextComponent(data.getSection("proxies").getSection(proxy).getString("display")); TextComponent message = new TextComponent("(master)");
TextComponent hover = new TextComponent(data.getSection("proxies").getSection(proxy).getString("display")); TextComponent hover = new TextComponent("(master)");
if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata")) { message.setColor(ChatColor.GRAY);
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
if (data.getKeys().contains("master-proxy")) {
hover = new TextComponent('\n' + data.getRawString("master-proxy"));
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent('\n' + plugin.api.getLang("SubServers", "Interface.Proxy-Menu.Proxy-Master"));
hoverm.add(hover);
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
msg.addExtra(message);
for (String proxy : data.getSection("proxies").getKeys()) {
hoverm = new LinkedList<TextComponent>();
message = new TextComponent(data.getSection("proxies").getSection(proxy).getString("display"));
hover = new TextComponent(data.getSection("proxies").getSection(proxy).getString("display"));
if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata") && data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message.setColor(ChatColor.GREEN);
hover.setColor(ChatColor.GREEN);
if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) {
hoverm.add(hover);
hover = new TextComponent('\n' + proxy);
hover.setColor(ChatColor.GRAY);
}
} else if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata")) {
message.setColor(ChatColor.AQUA); message.setColor(ChatColor.AQUA);
hover.setColor(ChatColor.AQUA); hover.setColor(ChatColor.AQUA);
} else { if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) {
hoverm.add(hover);
hover = new TextComponent('\n' + proxy);
hover.setColor(ChatColor.GRAY);
}
if (data.getKeys().contains("master-proxy")) {
hoverm.add(hover);
hover = new TextComponent('\n' + plugin.api.getLang("SubServers", "Interface.Proxy-Menu.Proxy-SubData"));
}
} else if (data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message.setColor(ChatColor.WHITE); message.setColor(ChatColor.WHITE);
hover.setColor(ChatColor.WHITE); hover.setColor(ChatColor.WHITE);
}
hoverm.add(hover); hoverm.add(hover);
if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) { if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) {
hover = new TextComponent('\n' + proxy); hover = new TextComponent('\n' + proxy);
hover.setColor(ChatColor.GRAY); hover.setColor(ChatColor.GRAY);
hoverm.add(hover); hoverm.add(hover);
} }
hover = new TextComponent('\n' + plugin.api.getLang("SubServers", "Interface.Proxy-Menu.Proxy-Redis"));
} else {
message.setColor(ChatColor.RED);
hover.setColor(ChatColor.RED);
hoverm.add(hover);
if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) {
hover = new TextComponent('\n' + proxy);
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent('\n' + plugin.api.getLang("SubServers", "Interface.Proxy-Menu.Proxy-Disconnected"));
}
hoverm.add(hover);
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()]))); message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
msg.addExtra(div); msg.addExtra(div);
msg.addExtra(message); msg.addExtra(message);

View File

@ -80,12 +80,20 @@ public class Proxy {
return raw.getRawString("display"); return raw.getRawString("display");
} }
/**
* Test if the proxy is connected to RedisBungee's server
*
* @return Redis Status
*/
public boolean isRedis() {
return raw.getBoolean("redis");
}
/** /**
* Get the players on this proxy (via RedisBungee) * Get the players on this proxy (via RedisBungee)
* *
* @return Player Collection * @return Player Collection
*/ */
@SuppressWarnings({"deprecation", "unchecked"})
public Collection<NamedContainer<String, UUID>> getPlayers() { public Collection<NamedContainer<String, UUID>> getPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>(); List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getSection("players").getKeys()) { for (String id : raw.getSection("players").getKeys()) {

View File

@ -156,7 +156,17 @@ public final class SubCommand implements CommandExecutor {
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Proxy-Header")); sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Proxy-Header"));
message = " (master)"; message = " (master)";
for (String proxy : data.getSection("proxies").getKeys()) { for (String proxy : data.getSection("proxies").getKeys()) {
message += div + ((data.getSection("proxies").getSection(proxy).getKeys().contains("subdata"))?ChatColor.AQUA:ChatColor.WHITE) + data.getSection("proxies").getSection(proxy).getString("display") + ((proxy.equals(data.getSection("proxies").getSection(proxy).getString("display")))?"":" ("+proxy+')'); message += div;
if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata") && data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message += ChatColor.GREEN;
} else if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata")) {
message += ChatColor.AQUA;
} else if (data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message += ChatColor.WHITE;
} else {
message += ChatColor.RED;
}
message += data.getSection("proxies").getSection(proxy).getString("display") + ((proxy.equals(data.getSection("proxies").getSection(proxy).getString("display")))?"":" ("+proxy+')');
} }
sender.sendMessage(message); sender.sendMessage(message);
} }

View File

@ -80,12 +80,20 @@ public class Proxy {
return raw.getRawString("display"); return raw.getRawString("display");
} }
/**
* Test if the proxy is connected to RedisBungee's server
*
* @return Redis Status
*/
public boolean isRedis() {
return raw.getBoolean("redis");
}
/** /**
* Get the players on this proxy (via RedisBungee) * Get the players on this proxy (via RedisBungee)
* *
* @return Player Collection * @return Player Collection
*/ */
@SuppressWarnings({"deprecation", "unchecked"})
public Collection<NamedContainer<String, UUID>> getPlayers() { public Collection<NamedContainer<String, UUID>> getPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>(); List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getSection("players").getKeys()) { for (String id : raw.getSection("players").getKeys()) {

View File

@ -399,23 +399,53 @@ public final class SubCommand implements CommandExecutor {
if (data.getSection("proxies").getKeys().size() > 0) { if (data.getSection("proxies").getKeys().size() > 0) {
sender.sendMessage(Text.of(plugin.api.getLang("SubServers", "Command.List.Proxy-Header"))); sender.sendMessage(Text.of(plugin.api.getLang("SubServers", "Command.List.Proxy-Header")));
msg = Text.builder(); msg = Text.builder();
for (String proxy : data.getSection("proxies").getKeys()) { Text.Builder message = Text.builder("(master)");
Text.Builder message = Text.builder(data.getSection("proxies").getSection(proxy).getString("display")); Text.Builder hover = Text.builder("(master)");
Text.Builder hover = Text.builder(data.getSection("proxies").getSection(proxy).getString("display")); message.color(TextColors.GRAY);
if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata")) { hover.color(TextColors.GRAY);
message.color(TextColors.AQUA); if (data.getKeys().contains("master-proxy")) {
hover.color(TextColors.AQUA); hover.append(Text.builder('\n' + data.getRawString("master-proxy")).color(TextColors.GRAY).build());
} else {
message.color(TextColors.WHITE);
hover.color(TextColors.WHITE);
} }
hover.append(Text.of('\n' + plugin.api.getLang("SubServers", "Interface.Proxy-Menu.Proxy-Master")));
message.onHover(TextActions.showText(hover.build()));
msg.append(message.build());
for (String proxy : data.getSection("proxies").getKeys()) {
message = Text.builder(data.getSection("proxies").getSection(proxy).getString("display"));
hover = Text.builder(data.getSection("proxies").getSection(proxy).getString("display"));
if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata") && data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message.color(TextColors.GREEN);
hover.color(TextColors.GREEN);
if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) { if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) {
hover.append(Text.builder('\n' + proxy).color(TextColors.GRAY).build()); hover.append(Text.builder('\n' + proxy).color(TextColors.GRAY).build());
} }
} else if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata")) {
message.color(TextColors.AQUA);
hover.color(TextColors.AQUA);
if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) {
hover.append(Text.builder('\n' + proxy).color(TextColors.GRAY).build());
}
if (data.getKeys().contains("master-proxy")) {
hover.append(Text.of('\n' + plugin.api.getLang("SubServers", "Interface.Proxy-Menu.Proxy-SubData")));
}
} else if (data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message.color(TextColors.WHITE);
hover.color(TextColors.WHITE);
if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) {
hover.append(Text.builder('\n' + proxy).color(TextColors.GRAY).build());
}
hover.append(Text.of('\n' + plugin.api.getLang("SubServers", "Interface.Proxy-Menu.Proxy-Redis")));
} else {
message.color(TextColors.RED);
hover.color(TextColors.RED);
if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) {
hover.append(Text.builder('\n' + proxy).color(TextColors.GRAY).build());
}
hover.append(Text.of('\n' + plugin.api.getLang("SubServers", "Interface.Proxy-Menu.Proxy-Disconnected")));
}
message.onHover(TextActions.showText(hover.build())); message.onHover(TextActions.showText(hover.build()));
msg.append(div, message.build()); msg.append(div, message.build());
} }
sender.sendMessage(Text.builder(" (master)").color(TextColors.GRAY).append(msg.build()).build()); sender.sendMessage(Text.builder(" ").append(msg.build()).build());
} }
})); }));
return CommandResult.builder().successCount(1).build(); return CommandResult.builder().successCount(1).build();

View File

@ -80,12 +80,20 @@ public class Proxy {
return raw.getRawString("display"); return raw.getRawString("display");
} }
/**
* Test if the proxy is connected to RedisBungee's server
*
* @return Redis Status
*/
public boolean isRedis() {
return raw.getBoolean("redis");
}
/** /**
* Get the players on this proxy (via RedisBungee) * Get the players on this proxy (via RedisBungee)
* *
* @return Player Collection * @return Player Collection
*/ */
@SuppressWarnings({"deprecation", "unchecked"})
public Collection<NamedContainer<String, UUID>> getPlayers() { public Collection<NamedContainer<String, UUID>> getPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>(); List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getSection("players").getKeys()) { for (String id : raw.getSection("players").getKeys()) {

View File

@ -177,7 +177,17 @@ public class SubCommand {
host.log.message.println("Proxy List:"); host.log.message.println("Proxy List:");
message = " (master)"; message = " (master)";
for (String proxy : data.getSection("proxies").getKeys()) { for (String proxy : data.getSection("proxies").getKeys()) {
message += div + ((data.getSection("proxies").getSection(proxy).getKeys().contains("subdata"))?TextColor.AQUA:TextColor.WHITE) + data.getSection("proxies").getSection(proxy).getString("display") + ((proxy.equals(data.getSection("proxies").getSection(proxy).getString("display")))?"":" ("+proxy+')'); message += div;
if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata") && data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message += TextColor.GREEN;
} else if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata")) {
message += TextColor.AQUA;
} else if (data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message += TextColor.WHITE;
} else {
message += TextColor.RED;
}
message += data.getSection("proxies").getSection(proxy).getString("display") + ((proxy.equals(data.getSection("proxies").getSection(proxy).getString("display")))?"":" ("+proxy+')');
} }
host.log.message.println(message); host.log.message.println(message);
} }

View File

@ -80,12 +80,20 @@ public class Proxy {
return raw.getRawString("display"); return raw.getRawString("display");
} }
/**
* Test if the proxy is connected to RedisBungee's server
*
* @return Redis Status
*/
public boolean isRedis() {
return raw.getBoolean("redis");
}
/** /**
* Get the players on this proxy (via RedisBungee) * Get the players on this proxy (via RedisBungee)
* *
* @return Player Collection * @return Player Collection
*/ */
@SuppressWarnings({"deprecation", "unchecked"})
public Collection<NamedContainer<String, UUID>> getPlayers() { public Collection<NamedContainer<String, UUID>> getPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>(); List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getSection("players").getKeys()) { for (String id : raw.getSection("players").getKeys()) {

View File

@ -166,7 +166,17 @@ public final class SubCommand extends CommandX {
sender.sendMessage("SubServers > Proxy List:"); sender.sendMessage("SubServers > Proxy List:");
message = " (master)"; message = " (master)";
for (String proxy : data.getSection("proxies").getKeys()) { for (String proxy : data.getSection("proxies").getKeys()) {
message += div + ((data.getSection("proxies").getSection(proxy).getKeys().contains("subdata"))?ChatColor.AQUA:ChatColor.WHITE) + data.getSection("proxies").getSection(proxy).getString("display") + ((proxy.equals(data.getSection("proxies").getSection(proxy).getString("display")))?"":" ("+proxy+')'); message += div;
if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata") && data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message += ChatColor.GREEN;
} else if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata")) {
message += ChatColor.AQUA;
} else if (data.getSection("proxies").getSection(proxy).getBoolean("redis")) {
message += ChatColor.WHITE;
} else {
message += ChatColor.RED;
}
message += data.getSection("proxies").getSection(proxy).getString("display") + ((proxy.equals(data.getSection("proxies").getSection(proxy).getString("display")))?"":" ("+proxy+')');
} }
sender.sendMessage(message); sender.sendMessage(message);
} }