Move Bungee Chat API methods to seperate class

This commit is contained in:
ME1312 2018-08-03 23:22:53 -04:00
parent 7f94e2115e
commit 65b29e666d
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
6 changed files with 287 additions and 299 deletions

View File

@ -10,7 +10,6 @@ import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
import net.ME1312.SubServers.Bungee.Library.NamedContainer;
import net.ME1312.SubServers.Bungee.Library.Util;
import net.ME1312.SubServers.Bungee.Library.Version.Version;
import net.ME1312.SubServers.Bungee.Library.Version.VersionType;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;
@ -19,17 +18,10 @@ import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.command.ConsoleCommandSender;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.*;

View File

@ -0,0 +1,283 @@
package net.ME1312.SubServers.Client.Bukkit.Library.Compatibility;
import net.ME1312.SubServers.Client.Bukkit.Library.Config.YAMLSection;
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.LinkedList;
import java.util.List;
public class BungeeChat {
private SubPlugin plugin;
public BungeeChat(SubPlugin plugin) {
this.plugin = plugin;
}
public void listCommand(CommandSender sender, String label, YAMLSection data) {
int i = 0;
boolean sent = false;
TextComponent div = new TextComponent(plugin.api.getLang("SubServers", "Command.List.Divider"));
if (data.getSection("groups").getKeys().size() > 0) {
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Group-Header"));
for (String group : data.getSection("groups").getKeys()) {
List<TextComponent> hoverm = new LinkedList<TextComponent>();
TextComponent msg = new TextComponent(" ");
TextComponent message = new TextComponent(group);
TextComponent hover = new TextComponent(group + '\n');
message.setColor(ChatColor.GOLD);
hover.setColor(ChatColor.GOLD);
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Group-Menu.Group-Server-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("groups").getSection(group).getKeys().size())));
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open Server 1 " + group));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
msg.addExtra(message);
msg.addExtra(new TextComponent(plugin.api.getLang("SubServers", "Command.List.Header")));
for (String server : data.getSection("groups").getSection(group).getKeys()) {
hoverm = new LinkedList<TextComponent>();
message = new TextComponent(data.getSection("groups").getSection(group).getSection(server).getString("display"));
hover = new TextComponent(data.getSection("groups").getSection(group).getSection(server).getString("display") + '\n');
if (data.getSection("groups").getSection(group).getSection(server).getKeys().contains("enabled")) {
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open SubServer/ " + server));
if (data.getSection("groups").getSection(group).getSection(server).getBoolean("temp")) {
message.setColor(ChatColor.AQUA);
hover.setColor(ChatColor.AQUA);
hoverm.add(hover);
if (!server.equals(data.getSection("groups").getSection(group).getSection(server).getString("display"))) {
hover = new TextComponent(server + '\n');
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("groups").getSection(group).getSection(server).getSection("players").getKeys().size())) + '\n');
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
} else if (data.getSection("groups").getSection(group).getSection(server).getBoolean("running")) {
message.setColor(ChatColor.GREEN);
hover.setColor(ChatColor.GREEN);
hoverm.add(hover);
if (!server.equals(data.getSection("groups").getSection(group).getSection(server).getString("display"))) {
hover = new TextComponent(server + '\n');
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("groups").getSection(group).getSection(server).getSection("players").getKeys().size())));
} else if (data.getSection("groups").getSection(group).getSection(server).getBoolean("enabled") && data.getSection("groups").getSection(group).getSection(server).getList("incompatible").size() == 0) {
message.setColor(ChatColor.YELLOW);
hover.setColor(ChatColor.YELLOW);
hoverm.add(hover);
if (!server.equals(data.getSection("groups").getSection(group).getSection(server).getString("display"))) {
hover = new TextComponent(server + '\n');
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Offline"));
} else {
message.setColor(ChatColor.RED);
hover.setColor(ChatColor.RED);
if (!server.equals(data.getSection("groups").getSection(group).getSection(server).getString("display"))) {
hoverm.add(hover);
hover = new TextComponent(server + '\n');
hover.setColor(ChatColor.GRAY);
}
if (data.getSection("groups").getSection(group).getSection(server).getList("incompatible").size() != 0) {
hoverm.add(hover);
String list = "";
for (int ii = 0; ii < data.getSection("groups").getSection(group).getSection(server).getList("incompatible").size(); ii++) {
if (list.length() != 0) list += ", ";
list += data.getSection("groups").getSection(group).getSection(server).getList("incompatible").get(ii).asString();
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Incompatible").replace("$str$", list) + ((data.getSection("groups").getSection(group).getSection(server).getBoolean("enabled"))?"":"\n"));
}
if (!data.getSection("groups").getSection(group).getSection(server).getBoolean("enabled")) {
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Disabled"));
}
}
hoverm.add(hover);
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + data.getSection("groups").getSection(group).getSection(server).getString("address"));
} else {
hover = new TextComponent('\n' + data.getSection("groups").getSection(group).getSection(server).getString("address").split(":")[data.getSection("groups").getSection(group).getSection(server).getString("address").split(":").length - 1]);
}
hover.setColor(ChatColor.WHITE);
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open SubServer/ " + server));
} else {
message.setColor(ChatColor.WHITE);
hover.setColor(ChatColor.WHITE);
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External"));
hoverm.add(hover);
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + data.getSection("servers").getSection(server).getString("address"));
} else {
hover = new TextComponent('\n' + data.getSection("servers").getSection(server).getString("address").split(":")[data.getSection("servers").getSection(server).getString("address").split(":").length - 1]);
}
hover.setColor(ChatColor.WHITE);
hoverm.add(hover);
}
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
if (i != 0) msg.addExtra(div);
msg.addExtra(message);
i++;
}
if (i == 0) msg.addExtra(new TextComponent(plugin.api.getLang("SubServers", "Command.List.Empty")));
((Player) sender).spigot().sendMessage(msg);
i = 0;
sent = true;
}
if (!sent) sender.sendMessage(" " + plugin.api.getLang("SubServers", "Command.List.Empty"));
sent = false;
}
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Host-Header"));
for (String host : data.getSection("hosts").getKeys()) {
List<TextComponent> hoverm = new LinkedList<TextComponent>();
TextComponent msg = new TextComponent(" ");
TextComponent message = new TextComponent(data.getSection("hosts").getSection(host).getString("display"));
TextComponent hover = new TextComponent(data.getSection("hosts").getSection(host).getString("display") + '\n');
if (data.getSection("hosts").getSection(host).getBoolean("enabled")) {
message.setColor(ChatColor.AQUA);
hover.setColor(ChatColor.AQUA);
hoverm.add(hover);
if (!host.equals(data.getSection("hosts").getSection(host).getString("display"))) {
hover = new TextComponent(host + '\n');
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Server-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("hosts").getSection(host).getSection("servers").getKeys().size())));
} else {
message.setColor(ChatColor.RED);
hover.setColor(ChatColor.RED);
hoverm.add(hover);
if (!host.equals(data.getSection("hosts").getSection(host).getString("display"))) {
hover = new TextComponent(host + '\n');
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Disabled"));
}
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hoverm.add(hover);
hover = new TextComponent('\n' + data.getSection("hosts").getSection(host).getString("address"));
hover.setColor(ChatColor.WHITE);
}
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open Host/ " + host));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
msg.addExtra(message);
msg.addExtra(new TextComponent(plugin.api.getLang("SubServers", "Command.List.Header")));
for (String subserver : data.getSection("hosts").getSection(host).getSection("servers").getKeys()) {
hoverm = new LinkedList<TextComponent>();
message = new TextComponent(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"));
hover = new TextComponent(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display") + '\n');
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open SubServer/ " + subserver));
if (data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("temp")) {
message.setColor(ChatColor.AQUA);
hover.setColor(ChatColor.AQUA);
hoverm.add(hover);
if (!subserver.equals(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"))) {
hover = new TextComponent(subserver + '\n');
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getSection("players").getKeys().size())) + '\n');
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
} else if (data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("running")) {
message.setColor(ChatColor.GREEN);
hover.setColor(ChatColor.GREEN);
hoverm.add(hover);
if (!subserver.equals(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"))) {
hover = new TextComponent(subserver + '\n');
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getSection("players").getKeys().size())));
} else if (data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("enabled") && data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getList("incompatible").size() == 0) {
message.setColor(ChatColor.YELLOW);
hover.setColor(ChatColor.YELLOW);
hoverm.add(hover);
if (!subserver.equals(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"))) {
hover = new TextComponent(subserver + '\n');
hover.setColor(ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Offline"));
} else {
message.setColor(ChatColor.RED);
hover.setColor(ChatColor.RED);
if (!subserver.equals(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"))) {
hoverm.add(hover);
hover = new TextComponent(subserver + '\n');
hover.setColor(ChatColor.GRAY);
}
if (data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getList("incompatible").size() != 0) {
hoverm.add(hover);
String list = "";
for (int ii = 0; ii < data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getList("incompatible").size(); ii++) {
if (list.length() != 0) list += ", ";
list += data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getList("incompatible").get(ii).asString();
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Incompatible").replace("$str$", list) + ((data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("enabled"))?"":"\n"));
}
if (!data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("enabled")) {
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Disabled"));
}
}
hoverm.add(hover);
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("address"));
} else {
hover = new TextComponent('\n' + data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("address").split(":")[data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("address").split(":").length - 1]);
}
hover.setColor(ChatColor.WHITE);
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open SubServer/ " + subserver));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
if (i != 0) msg.addExtra(div);
msg.addExtra(message);
i++;
}
if (i == 0) msg.addExtra(new TextComponent(plugin.api.getLang("SubServers", "Command.List.Empty")));
((Player) sender).spigot().sendMessage(msg);
i = 0;
sent = true;
}
if (!sent) sender.sendMessage(" " + plugin.api.getLang("SubServers", "Command.List.Empty"));
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Server-Header"));
TextComponent msg = new TextComponent(" ");
for (String server : data.getSection("servers").getKeys()) {
List<TextComponent> hoverm = new LinkedList<TextComponent>();
TextComponent message = new TextComponent(data.getSection("servers").getSection(server).getString("display"));
TextComponent hover = new TextComponent(data.getSection("servers").getSection(server).getString("display") + '\n');
message.setColor(ChatColor.WHITE);
hover.setColor(ChatColor.WHITE);
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External"));
hoverm.add(hover);
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + data.getSection("servers").getSection(server).getString("address"));
} else {
hover = new TextComponent('\n' + data.getSection("servers").getSection(server).getString("address").split(":")[data.getSection("servers").getSection(server).getString("address").split(":").length - 1]);
}
hover.setColor(ChatColor.WHITE);
hoverm.add(hover);
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
if (i != 0) msg.addExtra(div);
msg.addExtra(message);
i++;
}
if (i == 0) sender.sendMessage(" " + plugin.api.getLang("SubServers", "Command.List.Empty"));
((Player) sender).spigot().sendMessage(msg);
}
}

View File

@ -5,9 +5,6 @@ import net.ME1312.SubServers.Client.Bukkit.Library.Config.YAMLSection;
import net.ME1312.SubServers.Client.Bukkit.Library.Util;
import net.ME1312.SubServers.Client.Bukkit.Library.Version.Version;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.*;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -20,7 +17,6 @@ import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.nio.charset.Charset;
import java.text.DecimalFormat;
import java.util.*;
public final class SubCommand implements CommandExecutor {
@ -77,266 +73,11 @@ public final class SubCommand implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("list")) {
final String fLabel = label;
plugin.subdata.sendPacket(new PacketDownloadServerList(null, null, data -> {
int i = 0;
boolean sent = false;
if (sender instanceof Player) {
TextComponent div = new TextComponent(plugin.api.getLang("SubServers", "Command.List.Divider"));
if (data.getSection("groups").getKeys().size() > 0) {
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Group-Header"));
for (String group : data.getSection("groups").getKeys()) {
List<TextComponent> hoverm = new LinkedList<TextComponent>();
TextComponent msg = new TextComponent(" ");
TextComponent message = new TextComponent(group);
TextComponent hover = new TextComponent(group + '\n');
message.setColor(net.md_5.bungee.api.ChatColor.GOLD);
hover.setColor(net.md_5.bungee.api.ChatColor.GOLD);
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Group-Menu.Group-Server-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("groups").getSection(group).getKeys().size())));
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, fLabel + " open Server 1 " + group));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
msg.addExtra(message);
msg.addExtra(new TextComponent(plugin.api.getLang("SubServers", "Command.List.Header")));
for (String server : data.getSection("groups").getSection(group).getKeys()) {
hoverm = new LinkedList<TextComponent>();
message = new TextComponent(data.getSection("groups").getSection(group).getSection(server).getString("display"));
hover = new TextComponent(data.getSection("groups").getSection(group).getSection(server).getString("display") + '\n');
if (data.getSection("groups").getSection(group).getSection(server).getKeys().contains("enabled")) {
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, fLabel + " open SubServer/ " + server));
if (data.getSection("groups").getSection(group).getSection(server).getBoolean("temp")) {
message.setColor(net.md_5.bungee.api.ChatColor.AQUA);
hover.setColor(net.md_5.bungee.api.ChatColor.AQUA);
hoverm.add(hover);
if (!server.equals(data.getSection("groups").getSection(group).getSection(server).getString("display"))) {
hover = new TextComponent(server + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("groups").getSection(group).getSection(server).getSection("players").getKeys().size())) + '\n');
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
} else if (data.getSection("groups").getSection(group).getSection(server).getBoolean("running")) {
message.setColor(net.md_5.bungee.api.ChatColor.GREEN);
hover.setColor(net.md_5.bungee.api.ChatColor.GREEN);
hoverm.add(hover);
if (!server.equals(data.getSection("groups").getSection(group).getSection(server).getString("display"))) {
hover = new TextComponent(server + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("groups").getSection(group).getSection(server).getSection("players").getKeys().size())));
} else if (data.getSection("groups").getSection(group).getSection(server).getBoolean("enabled") && data.getSection("groups").getSection(group).getSection(server).getList("incompatible").size() == 0) {
message.setColor(net.md_5.bungee.api.ChatColor.YELLOW);
hover.setColor(net.md_5.bungee.api.ChatColor.YELLOW);
hoverm.add(hover);
if (!server.equals(data.getSection("groups").getSection(group).getSection(server).getString("display"))) {
hover = new TextComponent(server + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Offline"));
} else {
message.setColor(net.md_5.bungee.api.ChatColor.RED);
hover.setColor(net.md_5.bungee.api.ChatColor.RED);
if (!server.equals(data.getSection("groups").getSection(group).getSection(server).getString("display"))) {
hoverm.add(hover);
hover = new TextComponent(server + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
}
if (data.getSection("groups").getSection(group).getSection(server).getList("incompatible").size() != 0) {
hoverm.add(hover);
String list = "";
for (int ii = 0; ii < data.getSection("groups").getSection(group).getSection(server).getList("incompatible").size(); ii++) {
if (list.length() != 0) list += ", ";
list += data.getSection("groups").getSection(group).getSection(server).getList("incompatible").get(ii).asString();
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Incompatible").replace("$str$", list) + ((data.getSection("groups").getSection(group).getSection(server).getBoolean("enabled"))?"":"\n"));
}
if (!data.getSection("groups").getSection(group).getSection(server).getBoolean("enabled")) {
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Disabled"));
}
}
hoverm.add(hover);
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + data.getSection("groups").getSection(group).getSection(server).getString("address"));
} else {
hover = new TextComponent('\n' + data.getSection("groups").getSection(group).getSection(server).getString("address").split(":")[data.getSection("groups").getSection(group).getSection(server).getString("address").split(":").length - 1]);
}
hover.setColor(net.md_5.bungee.api.ChatColor.WHITE);
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, fLabel + " open SubServer/ " + server));
} else {
message.setColor(net.md_5.bungee.api.ChatColor.WHITE);
hover.setColor(net.md_5.bungee.api.ChatColor.WHITE);
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External"));
hoverm.add(hover);
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + data.getSection("servers").getSection(server).getString("address"));
} else {
hover = new TextComponent('\n' + data.getSection("servers").getSection(server).getString("address").split(":")[data.getSection("servers").getSection(server).getString("address").split(":").length - 1]);
}
hover.setColor(net.md_5.bungee.api.ChatColor.WHITE);
hoverm.add(hover);
}
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
if (i != 0) msg.addExtra(div);
msg.addExtra(message);
i++;
}
if (i == 0) msg.addExtra(new TextComponent(plugin.api.getLang("SubServers", "Command.List.Empty")));
((Player) sender).spigot().sendMessage(msg);
i = 0;
sent = true;
}
if (!sent) sender.sendMessage(" " + plugin.api.getLang("SubServers", "Command.List.Empty"));
sent = false;
}
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Host-Header"));
for (String host : data.getSection("hosts").getKeys()) {
List<TextComponent> hoverm = new LinkedList<TextComponent>();
TextComponent msg = new TextComponent(" ");
TextComponent message = new TextComponent(data.getSection("hosts").getSection(host).getString("display"));
TextComponent hover = new TextComponent(data.getSection("hosts").getSection(host).getString("display") + '\n');
if (data.getSection("hosts").getSection(host).getBoolean("enabled")) {
message.setColor(net.md_5.bungee.api.ChatColor.AQUA);
hover.setColor(net.md_5.bungee.api.ChatColor.AQUA);
hoverm.add(hover);
if (!host.equals(data.getSection("hosts").getSection(host).getString("display"))) {
hover = new TextComponent(host + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Server-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("hosts").getSection(host).getSection("servers").getKeys().size())));
} else {
message.setColor(net.md_5.bungee.api.ChatColor.RED);
hover.setColor(net.md_5.bungee.api.ChatColor.RED);
hoverm.add(hover);
if (!host.equals(data.getSection("hosts").getSection(host).getString("display"))) {
hover = new TextComponent(host + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Disabled"));
}
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hoverm.add(hover);
hover = new TextComponent('\n' + data.getSection("hosts").getSection(host).getString("address"));
hover.setColor(net.md_5.bungee.api.ChatColor.WHITE);
}
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, fLabel + " open Host/ " + host));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
msg.addExtra(message);
msg.addExtra(new TextComponent(plugin.api.getLang("SubServers", "Command.List.Header")));
for (String subserver : data.getSection("hosts").getSection(host).getSection("servers").getKeys()) {
hoverm = new LinkedList<TextComponent>();
message = new TextComponent(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"));
hover = new TextComponent(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display") + '\n');
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, fLabel + " open SubServer/ " + subserver));
if (data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("temp")) {
message.setColor(net.md_5.bungee.api.ChatColor.AQUA);
hover.setColor(net.md_5.bungee.api.ChatColor.AQUA);
hoverm.add(hover);
if (!subserver.equals(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"))) {
hover = new TextComponent(subserver + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getSection("players").getKeys().size())) + '\n');
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
} else if (data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("running")) {
message.setColor(net.md_5.bungee.api.ChatColor.GREEN);
hover.setColor(net.md_5.bungee.api.ChatColor.GREEN);
hoverm.add(hover);
if (!subserver.equals(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"))) {
hover = new TextComponent(subserver + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getSection("players").getKeys().size())));
} else if (data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("enabled") && data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getList("incompatible").size() == 0) {
message.setColor(net.md_5.bungee.api.ChatColor.YELLOW);
hover.setColor(net.md_5.bungee.api.ChatColor.YELLOW);
hoverm.add(hover);
if (!subserver.equals(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"))) {
hover = new TextComponent(subserver + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
hoverm.add(hover);
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Offline"));
} else {
message.setColor(net.md_5.bungee.api.ChatColor.RED);
hover.setColor(net.md_5.bungee.api.ChatColor.RED);
if (!subserver.equals(data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("display"))) {
hoverm.add(hover);
hover = new TextComponent(subserver + '\n');
hover.setColor(net.md_5.bungee.api.ChatColor.GRAY);
}
if (data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getList("incompatible").size() != 0) {
hoverm.add(hover);
String list = "";
for (int ii = 0; ii < data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getList("incompatible").size(); ii++) {
if (list.length() != 0) list += ", ";
list += data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getList("incompatible").get(ii).asString();
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Incompatible").replace("$str$", list) + ((data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("enabled"))?"":"\n"));
}
if (!data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getBoolean("enabled")) {
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Disabled"));
}
}
hoverm.add(hover);
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("address"));
} else {
hover = new TextComponent('\n' + data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("address").split(":")[data.getSection("hosts").getSection(host).getSection("servers").getSection(subserver).getString("address").split(":").length - 1]);
}
hover.setColor(net.md_5.bungee.api.ChatColor.WHITE);
hoverm.add(hover);
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, fLabel + " open SubServer/ " + subserver));
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
if (i != 0) msg.addExtra(div);
msg.addExtra(message);
i++;
}
if (i == 0) msg.addExtra(new TextComponent(plugin.api.getLang("SubServers", "Command.List.Empty")));
((Player) sender).spigot().sendMessage(msg);
i = 0;
sent = true;
}
if (!sent) sender.sendMessage(" " + plugin.api.getLang("SubServers", "Command.List.Empty"));
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Server-Header"));
TextComponent msg = new TextComponent(" ");
for (String server : data.getSection("servers").getKeys()) {
List<TextComponent> hoverm = new LinkedList<TextComponent>();
TextComponent message = new TextComponent(data.getSection("servers").getSection(server).getString("display"));
TextComponent hover = new TextComponent(data.getSection("servers").getSection(server).getString("display") + '\n');
message.setColor(net.md_5.bungee.api.ChatColor.WHITE);
hover.setColor(net.md_5.bungee.api.ChatColor.WHITE);
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External"));
hoverm.add(hover);
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + data.getSection("servers").getSection(server).getString("address"));
} else {
hover = new TextComponent('\n' + data.getSection("servers").getSection(server).getString("address").split(":")[data.getSection("servers").getSection(server).getString("address").split(":").length - 1]);
}
hover.setColor(net.md_5.bungee.api.ChatColor.WHITE);
hoverm.add(hover);
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverm.toArray(new TextComponent[hoverm.size()])));
if (i != 0) msg.addExtra(div);
msg.addExtra(message);
i++;
}
if (i == 0) sender.sendMessage(" " + plugin.api.getLang("SubServers", "Command.List.Empty"));
((Player) sender).spigot().sendMessage(msg);
if (Util.getDespiteException(() -> Class.forName("net.md_5.bungee.api.chat.BaseComponent") != null, false) && sender instanceof Player) {
new net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.BungeeChat(plugin).listCommand(sender, fLabel, data);
} else {
int i = 0;
boolean sent = false;
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Group-Header"));
String div = plugin.api.getLang("SubServers", "Command.List.Divider");

View File

@ -5,7 +5,6 @@ import net.ME1312.SubServers.Client.Sponge.Graphic.UIRenderer;
import net.ME1312.SubServers.Client.Sponge.Library.Config.YAMLSection;
import net.ME1312.SubServers.Client.Sponge.Library.Util;
import net.ME1312.SubServers.Client.Sponge.Library.Version.Version;
import net.ME1312.SubServers.Client.Sponge.Library.Version.VersionType;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.*;
import org.spongepowered.api.Platform;
import org.spongepowered.api.Sponge;
@ -21,16 +20,8 @@ import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.action.TextActions;
import org.spongepowered.api.text.format.TextColors;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.nio.charset.Charset;

View File

@ -6,19 +6,11 @@ import net.ME1312.SubServers.Host.Library.Config.YAMLSection;
import net.ME1312.SubServers.Host.Library.TextColor;
import net.ME1312.SubServers.Host.Library.Util;
import net.ME1312.SubServers.Host.Library.Version.Version;
import net.ME1312.SubServers.Host.Library.Version.VersionType;
import net.ME1312.SubServers.Host.Network.Packet.*;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.*;

View File

@ -6,7 +6,6 @@ import net.ME1312.SubServers.Sync.Library.Config.YAMLSection;
import net.ME1312.SubServers.Sync.Library.NamedContainer;
import net.ME1312.SubServers.Sync.Library.Util;
import net.ME1312.SubServers.Sync.Library.Version.Version;
import net.ME1312.SubServers.Sync.Library.Version.VersionType;
import net.ME1312.SubServers.Sync.Network.Packet.*;
import net.ME1312.SubServers.Sync.Server.Server;
import net.ME1312.SubServers.Sync.Server.SubServer;
@ -15,22 +14,12 @@ import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;
import net.md_5.bungee.command.ConsoleCommandSender;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.*;