mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-05 01:59:30 +01:00
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:
parent
a7e9185ce4
commit
38eec66a4b
@ -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)
|
||||
*
|
||||
@ -152,6 +163,7 @@ public class Proxy implements ClientHandler, ExtraDataHandler {
|
||||
players.set(player.get().toString(), pinfo);
|
||||
}
|
||||
info.set("players", players);
|
||||
info.set("redis", isRedis());
|
||||
if (getSubData() != null) info.set("subdata", getSubData().getAddress().toString());
|
||||
info.set("signature", signature);
|
||||
info.set("extra", getExtra());
|
||||
|
@ -80,6 +80,10 @@ Lang:
|
||||
'Interface.Generic.Downloading.Title-Color-Alt': '&3'
|
||||
'Interface.Generic.Downloading.Response': '&eWaiting for response'
|
||||
'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.Host-Disabled': '&4Disabled'
|
||||
'Interface.Host-Menu.Host-Server-Count': '&9$int$ Server(s)'
|
||||
|
@ -60,6 +60,7 @@ public class PacketDownloadServerList implements PacketIn, PacketOut {
|
||||
proxies.set(proxy.getName(), new YAMLSection(new Gson().fromJson(proxy.toString(), Map.class)));
|
||||
}
|
||||
data.set("proxies", proxies);
|
||||
if (plugin.redis) data.set("master-proxy", Util.getDespiteException(() -> plugin.redis("getServerId"), null));
|
||||
|
||||
YAMLSection exServers = new YAMLSection();
|
||||
for (Server server : plugin.exServers.values()) {
|
||||
|
@ -213,7 +213,17 @@ public final class SubCommand extends CommandX {
|
||||
sender.sendMessage("SubServers > Proxy List:");
|
||||
message = " (master)";
|
||||
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);
|
||||
}
|
||||
|
@ -289,25 +289,68 @@ public class BungeeChat {
|
||||
else ((Player) sender).spigot().sendMessage(msg);
|
||||
if (data.getSection("proxies").getKeys().size() > 0) {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Proxy-Header"));
|
||||
msg = new TextComponent(" (master)");
|
||||
msg.setColor(ChatColor.GRAY);
|
||||
msg = new TextComponent(" ");
|
||||
List<TextComponent> hoverm = new LinkedList<TextComponent>();
|
||||
TextComponent message = new TextComponent("(master)");
|
||||
TextComponent hover = new TextComponent("(master)");
|
||||
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()) {
|
||||
List<TextComponent> hoverm = new LinkedList<TextComponent>();
|
||||
TextComponent message = new TextComponent(data.getSection("proxies").getSection(proxy).getString("display"));
|
||||
TextComponent hover = new TextComponent(data.getSection("proxies").getSection(proxy).getString("display"));
|
||||
if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata")) {
|
||||
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);
|
||||
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);
|
||||
hover.setColor(ChatColor.WHITE);
|
||||
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-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);
|
||||
if (!proxy.equals(data.getSection("proxies").getSection(proxy).getString("display"))) {
|
||||
hover = new TextComponent('\n' + proxy);
|
||||
hover.setColor(ChatColor.GRAY);
|
||||
hoverm.add(hover);
|
||||
}
|
||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
|
||||
msg.addExtra(div);
|
||||
msg.addExtra(message);
|
||||
|
@ -80,12 +80,20 @@ public class Proxy {
|
||||
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)
|
||||
*
|
||||
* @return Player Collection
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "unchecked"})
|
||||
public Collection<NamedContainer<String, UUID>> getPlayers() {
|
||||
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
|
||||
for (String id : raw.getSection("players").getKeys()) {
|
||||
|
@ -156,7 +156,17 @@ public final class SubCommand implements CommandExecutor {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Proxy-Header"));
|
||||
message = " (master)";
|
||||
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);
|
||||
}
|
||||
|
@ -80,12 +80,20 @@ public class Proxy {
|
||||
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)
|
||||
*
|
||||
* @return Player Collection
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "unchecked"})
|
||||
public Collection<NamedContainer<String, UUID>> getPlayers() {
|
||||
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
|
||||
for (String id : raw.getSection("players").getKeys()) {
|
||||
|
@ -399,23 +399,53 @@ public final class SubCommand implements CommandExecutor {
|
||||
if (data.getSection("proxies").getKeys().size() > 0) {
|
||||
sender.sendMessage(Text.of(plugin.api.getLang("SubServers", "Command.List.Proxy-Header")));
|
||||
msg = Text.builder();
|
||||
Text.Builder message = Text.builder("(master)");
|
||||
Text.Builder hover = Text.builder("(master)");
|
||||
message.color(TextColors.GRAY);
|
||||
hover.color(TextColors.GRAY);
|
||||
if (data.getKeys().contains("master-proxy")) {
|
||||
hover.append(Text.builder('\n' + data.getRawString("master-proxy")).color(TextColors.GRAY).build());
|
||||
}
|
||||
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()) {
|
||||
Text.Builder message = Text.builder(data.getSection("proxies").getSection(proxy).getString("display"));
|
||||
Text.Builder hover = Text.builder(data.getSection("proxies").getSection(proxy).getString("display"));
|
||||
if (data.getSection("proxies").getSection(proxy).getKeys().contains("subdata")) {
|
||||
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"))) {
|
||||
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);
|
||||
} else {
|
||||
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());
|
||||
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()));
|
||||
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();
|
||||
|
@ -80,12 +80,20 @@ public class Proxy {
|
||||
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)
|
||||
*
|
||||
* @return Player Collection
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "unchecked"})
|
||||
public Collection<NamedContainer<String, UUID>> getPlayers() {
|
||||
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
|
||||
for (String id : raw.getSection("players").getKeys()) {
|
||||
|
@ -177,7 +177,17 @@ public class SubCommand {
|
||||
host.log.message.println("Proxy List:");
|
||||
message = " (master)";
|
||||
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);
|
||||
}
|
||||
|
@ -80,12 +80,20 @@ public class Proxy {
|
||||
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)
|
||||
*
|
||||
* @return Player Collection
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "unchecked"})
|
||||
public Collection<NamedContainer<String, UUID>> getPlayers() {
|
||||
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
|
||||
for (String id : raw.getSection("players").getKeys()) {
|
||||
|
@ -166,7 +166,17 @@ public final class SubCommand extends CommandX {
|
||||
sender.sendMessage("SubServers > Proxy List:");
|
||||
message = " (master)";
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user