From 4cfe1b42851e02643c4cd4f031fdef6859e25fbf Mon Sep 17 00:00:00 2001 From: ME1312 Date: Sat, 14 Nov 2020 13:12:08 -0500 Subject: [PATCH] Standardize RemotePlayer This is the RemotePlayer API, not the GlobalPlayer API. --- .../ME1312/SubServers/Bungee/BungeeAPI.java | 21 +++++--- .../ME1312/SubServers/Bungee/Host/Host.java | 4 +- .../ME1312/SubServers/Bungee/Host/Server.java | 2 +- .../SubServers/Bungee/Host/ServerImpl.java | 12 ++--- .../Packet/PacketDisconnectPlayer.java | 2 +- .../Packet/PacketDownloadPlatformInfo.java | 2 +- .../Packet/PacketDownloadPlayerInfo.java | 6 +-- .../net/ME1312/SubServers/Bungee/SubAPI.java | 39 ++++++++++++--- .../ME1312/SubServers/Bungee/SubCommand.java | 12 ++--- .../Bukkit/Graphic/DefaultUIRenderer.java | 6 +-- .../Library/Compatibility/BungeeChat.java | 8 ++-- .../Compatibility/PlaceholderImpl.java | 4 +- .../SubServers/Client/Bukkit/SubCommand.java | 4 +- SubServers.Client/Common/pom.xml | 48 +++++++++++++++++++ .../SubServers/Client/Common/ClientAPI.java | 12 ++--- .../Client/Common/Network/API/Host.java | 6 +-- .../Client/Common/Network/API/Server.java | 4 +- .../Common/Network/API/SimplifiedData.java | 6 +-- .../SubServers/Client/Sponge/SubCommand.java | 12 ++--- SubServers.Creator/pom.xml | 2 +- .../ME1312/SubServers/Host/SubCommand.java | 4 +- .../SubServers/Sync/Network/SubProtocol.java | 2 +- .../SubServers/Sync/Server/ServerImpl.java | 10 +--- .../net/ME1312/SubServers/Sync/SubAPI.java | 40 +++++++++++++--- .../ME1312/SubServers/Sync/SubCommand.java | 12 ++--- 25 files changed, 189 insertions(+), 91 deletions(-) diff --git a/SubServers.Bungee/common/src/net/ME1312/SubServers/Bungee/BungeeAPI.java b/SubServers.Bungee/common/src/net/ME1312/SubServers/Bungee/BungeeAPI.java index aa1078ab..23c8cc29 100644 --- a/SubServers.Bungee/common/src/net/ME1312/SubServers/Bungee/BungeeAPI.java +++ b/SubServers.Bungee/common/src/net/ME1312/SubServers/Bungee/BungeeAPI.java @@ -5,6 +5,7 @@ import net.ME1312.Galaxi.Library.Util; import net.ME1312.Galaxi.Library.Version.Version; import net.ME1312.SubServers.Bungee.Library.Compatibility.RemotePlayer; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.config.ServerInfo; import java.util.*; @@ -35,16 +36,22 @@ public interface BungeeAPI { * * @return Remote Player Collection */ - default int getRemotePlayerCount() { - return getGlobalPlayers().size(); - } + int getRemotePlayerCount(); + + /** + * Get players on this server across all known proxies + * + * @param server Server to search + * @return Remote Player Map + */ + Map getRemotePlayers(ServerInfo server); /** * Get players on this network across all known proxies * - * @return Remote Player Collection + * @return Remote Player Map */ - Map getGlobalPlayers(); + Map getRemotePlayers(); /** * Get a player on this network by searching across all known proxies @@ -52,7 +59,7 @@ public interface BungeeAPI { * @param name Player name * @return Remote Player */ - RemotePlayer getGlobalPlayer(String name); + RemotePlayer getRemotePlayer(String name); /** * Get a player on this network by searching across all known proxies @@ -60,7 +67,7 @@ public interface BungeeAPI { * @param id Player UUID * @return Remote Player */ - RemotePlayer getGlobalPlayer(UUID id); + RemotePlayer getRemotePlayer(UUID id); /** * Gets the current SubServers Lang Channels diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Host.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Host.java index eb3337b2..f7dc15b5 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Host.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Host.java @@ -127,10 +127,10 @@ public abstract class Host implements ExtraDataHandler { * * @return Remote Player Collection */ - public Collection getGlobalPlayers() { + public Collection getRemotePlayers() { LinkedList players = new LinkedList(); for (SubServer server : getSubServers().values()) { - players.addAll(server.getGlobalPlayers()); + players.addAll(server.getRemotePlayers()); } return players; } diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Server.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Server.java index 0d6ba2fe..f93ffc68 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Server.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Server.java @@ -63,7 +63,7 @@ public interface Server extends ServerInfo, ClientHandler, ExtraDataHandler { * * @return Remote Player Collection */ - Collection getGlobalPlayers(); + Collection getRemotePlayers(); /** * If the server is hidden from players diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/ServerImpl.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/ServerImpl.java index 6c6706ba..0efe8bbd 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/ServerImpl.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/ServerImpl.java @@ -158,15 +158,9 @@ public class ServerImpl extends BungeeServerInfo implements Server { Collections.sort(groups); } - @SuppressWarnings("deprecation") @Override - public Collection getGlobalPlayers() { - SubProxy plugin = SubAPI.getInstance().getInternals(); - ArrayList players = new ArrayList(); - for (UUID id : Util.getBackwards(plugin.rPlayerLinkS, this)) { - players.add(plugin.rPlayers.get(id)); - } - return players; + public Collection getRemotePlayers() { + return SubAPI.getInstance().getRemotePlayers(this).values(); } @Override @@ -286,7 +280,7 @@ public class ServerImpl extends BungeeServerInfo implements Server { info.set("restricted", isRestricted()); info.set("hidden", isHidden()); ObjectMap players = new ObjectMap(); - for (RemotePlayer player : getGlobalPlayers()) + for (RemotePlayer player : getRemotePlayers()) players.set(player.getUniqueId().toString(), player.getName()); info.set("players", players); ObjectMap subdata = new ObjectMap(); diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDisconnectPlayer.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDisconnectPlayer.java index 9849615c..35597ee7 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDisconnectPlayer.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDisconnectPlayer.java @@ -66,7 +66,7 @@ public class PacketDisconnectPlayer implements PacketObjectIn, PacketOb local.disconnect(); } client.sendPacket(new PacketDisconnectPlayer(0, tracker)); - } else if ((remote = plugin.api.getGlobalPlayer(id)) != null) { + } else if ((remote = plugin.api.getRemotePlayer(id)) != null) { if (remote.getProxy().getSubData()[0] != null) { ((SubDataClient) remote.getProxy().getSubData()[0]).sendPacket(new PacketExDisconnectPlayer(remote.getUniqueId(), (data.contains(0x0002)?data.getRawString(0x0002):null), r -> { client.sendPacket(new PacketDisconnectPlayer(r.getInt(0x0001), tracker)); diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadPlatformInfo.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadPlatformInfo.java index d1960e54..a93b812e 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadPlatformInfo.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadPlatformInfo.java @@ -70,7 +70,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn, Pack LinkedList mcversions = new LinkedList(); for (Version version : plugin.api.getGameVersion()) mcversions.add(version.toString()); minecraft.set("version", mcversions); - minecraft.set("players", plugin.api.getGlobalPlayers().size()); + minecraft.set("players", plugin.api.getRemotePlayers().size()); info.set("minecraft", minecraft); ObjectMap system = new ObjectMap(); ObjectMap os = new ObjectMap(); diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadPlayerInfo.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadPlayerInfo.java index 05f7e6da..03833f66 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadPlayerInfo.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadPlayerInfo.java @@ -61,16 +61,16 @@ public class PacketDownloadPlayerInfo implements PacketObjectIn, Packet ObjectMap players = new ObjectMap(); if (ids == null && names == null) { - for (RemotePlayer player : plugin.api.getGlobalPlayers().values()) { + for (RemotePlayer player : plugin.api.getRemotePlayers().values()) { players.set(player.getUniqueId().toString(), player.forSubData()); } } else { if (ids != null) for (UUID id : ids) { - RemotePlayer player = plugin.api.getGlobalPlayer(id); + RemotePlayer player = plugin.api.getRemotePlayer(id); if (player != null) players.set(player.getUniqueId().toString(), player.forSubData()); } if (names != null) for (String name : names) { - RemotePlayer player = plugin.api.getGlobalPlayer(name); + RemotePlayer player = plugin.api.getRemotePlayer(name); if (player != null) players.set(player.getUniqueId().toString(), player.forSubData()); } } diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubAPI.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubAPI.java index 95232ba4..dc2e6939 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubAPI.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubAPI.java @@ -15,6 +15,7 @@ import net.ME1312.Galaxi.Library.UniversalFile; import net.ME1312.Galaxi.Library.Util; import net.ME1312.Galaxi.Library.Version.Version; import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException; +import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.protocol.ProtocolConstants; import java.lang.reflect.InvocationTargetException; @@ -544,12 +545,38 @@ public final class SubAPI implements BungeeAPI { return plugin.mProxy; } + /** + * Get the number of players on this network across all known proxies + * + * @return Remote Player Count + */ + public int getRemotePlayerCount() { + return plugin.rPlayers.size(); + } + + /** + * Get players on this server across all known proxies + * + * @param server Server to search + * @return Remote Player Map + */ + public Map getRemotePlayers(ServerInfo server) { + if (server instanceof Server) { + HashMap players = new HashMap(); + for (UUID id : Util.getBackwards(plugin.rPlayerLinkS, (Server) server)) + players.put(id, plugin.rPlayers.get(id)); + return players; + } else { + return new HashMap<>(); + } + } + /** * Get players on this network across all known proxies * - * @return Remote Player Collection + * @return Remote Player Map */ - public Map getGlobalPlayers() { + public Map getRemotePlayers() { return new HashMap(plugin.rPlayers); } @@ -559,9 +586,9 @@ public final class SubAPI implements BungeeAPI { * @param name Player name * @return Remote Player */ - public RemotePlayer getGlobalPlayer(String name) { + public RemotePlayer getRemotePlayer(String name) { if (Util.isNull(name)) throw new NullPointerException(); - for (RemotePlayer player : getGlobalPlayers().values()) { + for (RemotePlayer player : getRemotePlayers().values()) { if (player.getName().equalsIgnoreCase(name)) return player; } return null; @@ -573,9 +600,9 @@ public final class SubAPI implements BungeeAPI { * @param id Player UUID * @return Remote Player */ - public RemotePlayer getGlobalPlayer(UUID id) { + public RemotePlayer getRemotePlayer(UUID id) { if (Util.isNull(id)) throw new NullPointerException(); - return getGlobalPlayers().getOrDefault(id, null); + return getRemotePlayers().getOrDefault(id, null); } /** diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java index c9a300db..4374a417 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java @@ -267,7 +267,7 @@ public final class SubCommand extends CommandX { String name = args[(type != null)?2:1]; Runnable getPlayer = () -> { - RemotePlayer player = plugin.api.getGlobalPlayer(name); + RemotePlayer player = plugin.api.getRemotePlayer(name); if (player != null) { sender.sendMessage("SubServers > Info on player: " + ChatColor.WHITE + player.getName()); if (player.getProxy() != null) sender.sendMessage(" -> Proxy: " + ChatColor.WHITE + player.getProxy().getName()); @@ -300,7 +300,7 @@ public final class SubCommand extends CommandX { if (server instanceof SubServer) sender.sendMessage(" -> " + ((((SubServer) server).isOnline())?"Online":"Running") + ": " + ((((SubServer) server).isRunning())?ChatColor.GREEN+"yes":ChatColor.RED+"no")); if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) { sender.sendMessage(" -> Connected: " + ((server.getSubData()[0] != null)?ChatColor.GREEN+"yes"+((server.getSubData().length > 1)?ChatColor.AQUA+" +"+(server.getSubData().length-1)+" subchannel"+((server.getSubData().length == 2)?"":"s"):""):ChatColor.RED+"no")); - sender.sendMessage(" -> Players: " + ChatColor.AQUA + server.getGlobalPlayers().size() + " online"); + sender.sendMessage(" -> Players: " + ChatColor.AQUA + server.getRemotePlayers().size() + " online"); } sender.sendMessage(" -> MOTD: " + ChatColor.WHITE + ChatColor.stripColor(server.getMotd())); if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(" -> Stop Action: " + ChatColor.WHITE + ((SubServer) server).getStopAction().toString()); @@ -893,7 +893,7 @@ public final class SubCommand extends CommandX { ReturnRunnable> getPlayers = () -> { LinkedList names = new LinkedList(); for (ProxiedPlayer player : plugin.getPlayers()) names.add(player.getName()); - for (RemotePlayer player : plugin.api.getGlobalPlayers().values()) if (!names.contains(player.getName())) names.add(player.getName()); + for (RemotePlayer player : plugin.api.getRemotePlayers().values()) if (!names.contains(player.getName())) names.add(player.getName()); Collections.sort(names); return names; }; @@ -1109,7 +1109,7 @@ public final class SubCommand extends CommandX { } if (((ProxiedPlayer) sender).getServer().getInfo() instanceof Server) { - for (RemotePlayer player : ((Server) ((ProxiedPlayer) sender).getServer().getInfo()).getGlobalPlayers()) { + for (RemotePlayer player : ((Server) ((ProxiedPlayer) sender).getServer().getInfo()).getRemotePlayers()) { if (!used.contains(player.getUniqueId())) { if (player.getName().toLowerCase().startsWith(last)) list.add(Last + player.getName().substring(last.length())); used.add(player.getUniqueId()); @@ -1186,7 +1186,7 @@ public final class SubCommand extends CommandX { if (i != 0) serverm.addExtra(div); TextComponent message = new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.List").replace("$str$", server.getDisplayName())); try { - message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.Hover").replace("$int$", Integer.toString(server.getGlobalPlayers().size())))})); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.Hover").replace("$int$", Integer.toString(server.getRemotePlayers().size())))})); } catch (Exception e) { e.printStackTrace(); } @@ -1259,7 +1259,7 @@ public final class SubCommand extends CommandX { int players = 0; for (Server server : plugin.api.getServers().values()) { List playerlist = new ArrayList(); - for (RemotePlayer player : server.getGlobalPlayers()) playerlist.add(player.getName()); + for (RemotePlayer player : server.getRemotePlayers()) playerlist.add(player.getName()); Collections.sort(playerlist); players += playerlist.size(); diff --git a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Graphic/DefaultUIRenderer.java b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Graphic/DefaultUIRenderer.java index 6fa68421..55193f17 100644 --- a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Graphic/DefaultUIRenderer.java +++ b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Graphic/DefaultUIRenderer.java @@ -841,7 +841,7 @@ public class DefaultUIRenderer extends UIRenderer { if (!server.getName().equals(server.getDisplayName())) lore.add(ChatColor.GRAY + server.getName()); lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External")); - lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size()))); + lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size()))); lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Invalid")); lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort()); blockMeta.setLore(lore); @@ -856,7 +856,7 @@ public class DefaultUIRenderer extends UIRenderer { blockMeta.setDisplayName(ChatColor.AQUA + server.getDisplayName()); lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary")); } else blockMeta.setDisplayName(ChatColor.GREEN + server.getDisplayName()); - lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size()))); + lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size()))); lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort()); blockMeta.setLore(lore); } else if (((SubServer) server).isAvailable() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) { @@ -1132,7 +1132,7 @@ public class DefaultUIRenderer extends UIRenderer { blockMeta.setDisplayName(ChatColor.AQUA + subserver.getDisplayName()); lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary")); } else blockMeta.setDisplayName(ChatColor.GREEN + subserver.getDisplayName()); - lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getGlobalPlayers().size()))); + lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getRemotePlayers().size()))); lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort()); blockMeta.setLore(lore); } else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) { diff --git a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Library/Compatibility/BungeeChat.java b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Library/Compatibility/BungeeChat.java index 34535d9d..a2f05d5b 100644 --- a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Library/Compatibility/BungeeChat.java +++ b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Library/Compatibility/BungeeChat.java @@ -62,7 +62,7 @@ public class BungeeChat { hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary") + '\n'); hoverm.add(hover); } - hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size())) + ChatColor.RESET); + hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size())) + ChatColor.RESET); } else if (((SubServer) server).isAvailable() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) { message.setColor(ChatColor.YELLOW); hover.setColor(ChatColor.YELLOW); @@ -115,7 +115,7 @@ public class BungeeChat { hoverm.add(hover); hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External") + '\n'); hoverm.add(hover); - hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size())) + ChatColor.RESET); + hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size())) + ChatColor.RESET); hoverm.add(hover); if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) { hover = new TextComponent('\n' + server.getAddress().getAddress().getHostAddress() + ':' + server.getAddress().getPort()); @@ -196,7 +196,7 @@ public class BungeeChat { hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary") + '\n'); hoverm.add(hover); } - hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getGlobalPlayers().size())) + ChatColor.RESET); + hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getRemotePlayers().size())) + ChatColor.RESET); } else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) { message.setColor(ChatColor.YELLOW); hover.setColor(ChatColor.YELLOW); @@ -265,7 +265,7 @@ public class BungeeChat { } hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External") + '\n'); hoverm.add(hover); - hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size())) + ChatColor.RESET); + hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size())) + ChatColor.RESET); hoverm.add(hover); if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) { hover = new TextComponent('\n' + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort()); diff --git a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Library/Compatibility/PlaceholderImpl.java b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Library/Compatibility/PlaceholderImpl.java index 1436b20c..ea838a47 100644 --- a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Library/Compatibility/PlaceholderImpl.java +++ b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Library/Compatibility/PlaceholderImpl.java @@ -474,7 +474,7 @@ public class PlaceholderImpl extends PlaceholderExpansion implements Taskable, C return Integer.toString(host.getSubServers().size()); } case "host.players": { - return Integer.toString(host.getGlobalPlayers().size()); + return Integer.toString(host.getRemotePlayers().size()); } case "host.subdata": { return defaults(responses, ChatColor.GREEN+"Connected", ChatColor.YELLOW+"Unsupported", ChatColor.RED+"Disconnected") [(host.getSubData().length <= 0)?1:((host.getSubData()[0] == null)?2:0)]; @@ -520,7 +520,7 @@ public class PlaceholderImpl extends PlaceholderExpansion implements Taskable, C } case "server.players": case "subserver.players": { - return Integer.toString(server.getGlobalPlayers().size()); + return Integer.toString(server.getRemotePlayers().size()); } case "server.subdata": case "subserver.subdata": { diff --git a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/SubCommand.java b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/SubCommand.java index f6b6041f..75f8ba4c 100644 --- a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/SubCommand.java +++ b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/SubCommand.java @@ -197,7 +197,7 @@ public final class SubCommand extends BukkitCommand { String type = (args.length > 2)?args[1]:null; String name = args[(type != null)?2:1]; - Runnable getPlayer = () -> plugin.api.getGlobalPlayer(name, player -> { + Runnable getPlayer = () -> plugin.api.getRemotePlayer(name, player -> { if (player != null) { sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info").replace("$str$", "player") + ChatColor.WHITE + player.getName()); if (player.getProxy() != null) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Proxy") + ChatColor.WHITE + player.getProxy()); @@ -231,7 +231,7 @@ public final class SubCommand extends BukkitCommand { if (server instanceof SubServer) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", ((((SubServer) server).isOnline())?"Online":"Running")) + ((((SubServer) server).isRunning())?ChatColor.GREEN+"yes":ChatColor.RED+"no")); if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) { sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Connected") + ((server.getSubData()[0] != null)?ChatColor.GREEN+"yes"+((server.getSubData().length > 1)?ChatColor.AQUA+" +"+(server.getSubData().length-1)+" subchannel"+((server.getSubData().length == 2)?"":"s"):""):ChatColor.RED+"no")); - sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Players") + ChatColor.AQUA + server.getGlobalPlayers().size() + " online"); + sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Players") + ChatColor.AQUA + server.getRemotePlayers().size() + " online"); } sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "MOTD") + ChatColor.WHITE + ChatColor.stripColor(server.getMotd())); if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Stop Action") + ChatColor.WHITE + ((SubServer) server).getStopAction().toString()); diff --git a/SubServers.Client/Common/pom.xml b/SubServers.Client/Common/pom.xml index 77822030..49093358 100644 --- a/SubServers.Client/Common/pom.xml +++ b/SubServers.Client/Common/pom.xml @@ -52,6 +52,54 @@ 1.8 + + org.apache.maven.plugins + maven-assembly-plugin + 2.2-beta-5 + + SubServers.Client.Common + ../../Artifacts/Modulized + + jar-with-dependencies + + false + + + + make-assembly + package + + single + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.0 + + + generate-sources + + javadoc + + + SubServers.Client.Common Javadoc + SubServers.Client.Common Javadoc + protected + ./ + ${basedir}/../../Javadoc/SubServers.Client.Common + ${basedir}/../../Javadoc/SubServers.Client.Common + -Xdoclint:none + + https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiUtil/ + https://dev.me1312.net/jenkins/job/SubData/javadoc/Client/ + + + + + \ No newline at end of file diff --git a/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/ClientAPI.java b/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/ClientAPI.java index f9744d15..3d811b6a 100644 --- a/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/ClientAPI.java +++ b/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/ClientAPI.java @@ -324,8 +324,8 @@ public abstract class ClientAPI { * * @param callback Remote Player Collection */ - public void getGlobalPlayers(Callback> callback) { - requestGlobalPlayers(null, callback); + public void getRemotePlayers(Callback> callback) { + requestRemotePlayers(null, callback); } /** @@ -334,8 +334,8 @@ public abstract class ClientAPI { * @param name Player name * @param callback Remote Player */ - public void getGlobalPlayer(String name, Callback callback) { - requestGlobalPlayer(null, name, callback); + public void getRemotePlayer(String name, Callback callback) { + requestRemotePlayer(null, name, callback); } /** @@ -344,8 +344,8 @@ public abstract class ClientAPI { * @param id Player UUID * @param callback Remote Player */ - public void getGlobalPlayer(UUID id, Callback callback) { - requestGlobalPlayer(null, id, callback); + public void getRemotePlayer(UUID id, Callback callback) { + requestRemotePlayer(null, id, callback); } /** diff --git a/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/Host.java b/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/Host.java index 8862849e..faef2656 100644 --- a/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/Host.java +++ b/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/Host.java @@ -161,7 +161,7 @@ public class Host { * * @return Remote Player Collection */ - public Collection> getGlobalPlayers() { + public Collection> getRemotePlayers() { List> players = new ArrayList>(); for (String id : raw.getMap("players").getKeys()) { players.add(new ContainedPair(raw.getMap("players").getRawString(id), UUID.fromString(id))); @@ -174,7 +174,7 @@ public class Host { * * @param callback Remote Player Collection */ - public void getGlobalPlayers(Callback> callback) { + public void getRemotePlayers(Callback> callback) { if (Util.isNull(callback)) throw new NullPointerException(); StackTraceElement[] origin = new Exception().getStackTrace(); Runnable run = () -> { @@ -189,7 +189,7 @@ public class Host { if (players == null) { LinkedList ids = new LinkedList(); - for (SubServer server : getSubServers().values()) for (Pair player : server.getGlobalPlayers()) ids.add(player.value()); + for (SubServer server : getSubServers().values()) for (Pair player : server.getRemotePlayers()) ids.add(player.value()); client().sendPacket(new PacketDownloadPlayerInfo(ids, data -> { LinkedList players = new LinkedList(); for (String player : data.getKeys()) { diff --git a/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/Server.java b/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/Server.java index ce2a8995..10173f4a 100644 --- a/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/Server.java +++ b/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/Server.java @@ -125,7 +125,7 @@ public class Server { * * @return Remote Player Collection */ - public Collection> getGlobalPlayers() { + public Collection> getRemotePlayers() { List> players = new ArrayList>(); for (String id : raw.getMap("players").getKeys()) { players.add(new ContainedPair(raw.getMap("players").getRawString(id), UUID.fromString(id))); @@ -138,7 +138,7 @@ public class Server { * * @param callback Remote Player Collection */ - public void getGlobalPlayers(Callback> callback) { + public void getRemotePlayers(Callback> callback) { if (Util.isNull(callback)) throw new NullPointerException(); StackTraceElement[] origin = new Exception().getStackTrace(); Runnable run = () -> { diff --git a/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/SimplifiedData.java b/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/SimplifiedData.java index 55c5747b..f1053c13 100644 --- a/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/SimplifiedData.java +++ b/SubServers.Client/Common/src/net/ME1312/SubServers/Client/Common/Network/API/SimplifiedData.java @@ -328,7 +328,7 @@ public final class SimplifiedData { * @param client SubData connection * @param callback Remote Player Collection */ - public static void requestGlobalPlayers(DataClient client, Callback> callback) { + public static void requestRemotePlayers(DataClient client, Callback> callback) { if (Util.isNull(callback)) throw new NullPointerException(); StackTraceElement[] origin = new Exception().getStackTrace(); client(client).sendPacket(new PacketDownloadPlayerInfo((List) null, data -> { @@ -354,7 +354,7 @@ public final class SimplifiedData { * @param name Player name * @param callback Remote Player */ - public static void requestGlobalPlayer(DataClient client, String name, Callback callback) { + public static void requestRemotePlayer(DataClient client, String name, Callback callback) { if (Util.isNull(name, callback)) throw new NullPointerException(); StackTraceElement[] origin = new Exception().getStackTrace(); client(client).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(name), data -> { @@ -380,7 +380,7 @@ public final class SimplifiedData { * @param id Player UUID * @param callback Remote Player */ - public static void requestGlobalPlayer(DataClient client, UUID id, Callback callback) { + public static void requestRemotePlayer(DataClient client, UUID id, Callback callback) { if (Util.isNull(id, callback)) throw new NullPointerException(); StackTraceElement[] origin = new Exception().getStackTrace(); client(client).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(id), data -> { diff --git a/SubServers.Client/Sponge/src/net/ME1312/SubServers/Client/Sponge/SubCommand.java b/SubServers.Client/Sponge/src/net/ME1312/SubServers/Client/Sponge/SubCommand.java index 60624555..7a082179 100644 --- a/SubServers.Client/Sponge/src/net/ME1312/SubServers/Client/Sponge/SubCommand.java +++ b/SubServers.Client/Sponge/src/net/ME1312/SubServers/Client/Sponge/SubCommand.java @@ -249,7 +249,7 @@ public final class SubCommand implements CommandExecutor { hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.SubServer-Temporary") + '\n')); } hover.append( - ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size()))) + ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size()))) ); } else if (((SubServer) server).isAvailable() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) { message.color(TextColors.YELLOW); @@ -292,7 +292,7 @@ public final class SubCommand implements CommandExecutor { } hover.append( ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-External") + '\n'), - ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size()))) + ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size()))) ); if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) { hover.append(Text.builder('\n' + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort()).color(TextColors.WHITE).build()); @@ -354,7 +354,7 @@ public final class SubCommand implements CommandExecutor { hover.color(TextColors.AQUA); hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.SubServer-Temporary") + '\n')); } - hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getGlobalPlayers().size())))); + hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getRemotePlayers().size())))); } else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) { message.color(TextColors.YELLOW); hover.color(TextColors.YELLOW); @@ -409,7 +409,7 @@ public final class SubCommand implements CommandExecutor { } hover.append( ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-External") + '\n'), - ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size())))); + ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getRemotePlayers().size())))); if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) { hover.append(Text.builder('\n' + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort()).color(TextColors.WHITE).build()); } else { @@ -488,7 +488,7 @@ public final class SubCommand implements CommandExecutor { String name = n.get(); - Runnable getPlayer = () -> plugin.api.getGlobalPlayer(name, player -> { + Runnable getPlayer = () -> plugin.api.getRemotePlayer(name, player -> { if (player != null) { sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info").replace("$str$", "player")).toBuilder().append(Text.builder(player.getName()).color(TextColors.WHITE).build()).build()); if (player.getProxy() != null) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Proxy")).toBuilder().append(Text.builder(player.getProxy()).color(TextColors.WHITE).build()).build()); @@ -522,7 +522,7 @@ public final class SubCommand implements CommandExecutor { if (server instanceof SubServer) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", ((((SubServer) server).isOnline())?"Online":"Running"))).toBuilder().append(Text.builder((((SubServer) server).isRunning())?"yes":"no").color((((SubServer) server).isRunning())?TextColors.GREEN:TextColors.RED).build()).build()); if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) { sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Connected")).toBuilder().append(Text.builder((server.getSubData()[0] != null)?"yes":"no").color((server.getSubData()[0] != null)?TextColors.GREEN:TextColors.RED).build(), Text.builder((server.getSubData().length > 1)?" +"+(server.getSubData().length-1)+" subchannel"+((server.getSubData().length == 2)?"":"s"):"").color(TextColors.AQUA).build()).build()); - sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Players")).toBuilder().append(Text.builder(server.getGlobalPlayers().size() + " online").color(TextColors.AQUA).build()).build()); + sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Players")).toBuilder().append(Text.builder(server.getRemotePlayers().size() + " online").color(TextColors.AQUA).build()).build()); } sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "MOTD")).toBuilder().append(Text.builder(server.getMotd().replaceAll("\\u00A7[0-9a-fA-Fk-oK-ORr]", "")).color(TextColors.WHITE).build()).build()); if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Stop Action")).toBuilder().append(Text.builder(((SubServer) server).getStopAction().toString()).color(TextColors.WHITE).build()).build()); diff --git a/SubServers.Creator/pom.xml b/SubServers.Creator/pom.xml index bba4ec74..eee22dfd 100644 --- a/SubServers.Creator/pom.xml +++ b/SubServers.Creator/pom.xml @@ -7,5 +7,5 @@ -PLACEHOLDER pom - + \ No newline at end of file diff --git a/SubServers.Host/src/net/ME1312/SubServers/Host/SubCommand.java b/SubServers.Host/src/net/ME1312/SubServers/Host/SubCommand.java index f2aee9ff..f0d53b59 100644 --- a/SubServers.Host/src/net/ME1312/SubServers/Host/SubCommand.java +++ b/SubServers.Host/src/net/ME1312/SubServers/Host/SubCommand.java @@ -187,7 +187,7 @@ public class SubCommand { String type = (args.length > 1)?args[0]:null; String name = args[(type != null)?1:0]; - Runnable getPlayer = () -> host.api.getGlobalPlayer(name, player -> { + Runnable getPlayer = () -> host.api.getRemotePlayer(name, player -> { if (player != null) { sender.sendMessage("Info on player: " + TextColor.WHITE + player.getName()); if (player.getProxy() != null) sender.sendMessage(" -> Proxy: " + TextColor.WHITE + player.getProxy()); @@ -219,7 +219,7 @@ public class SubCommand { if (server instanceof SubServer) sender.sendMessage(" -> " + ((((SubServer) server).isOnline())?"Online":"Running") + ": " + ((((SubServer) server).isRunning())?TextColor.GREEN+"yes":TextColor.RED+"no")); if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) { sender.sendMessage(" -> Connected: " + ((server.getSubData()[0] != null)?TextColor.GREEN+"yes"+((server.getSubData().length > 1)?TextColor.AQUA+" +"+(server.getSubData().length-1)+" subchannel"+((server.getSubData().length == 2)?"":"s"):""):TextColor.RED+"no")); - sender.sendMessage(" -> Players: " + TextColor.AQUA + server.getGlobalPlayers().size() + " online"); + sender.sendMessage(" -> Players: " + TextColor.AQUA + server.getRemotePlayers().size() + " online"); } sender.sendMessage(" -> MOTD: " + TextColor.WHITE + TextColor.stripColor(server.getMotd())); if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(" -> Stop Action: " + TextColor.WHITE + ((SubServer) server).getStopAction().toString()); diff --git a/SubServers.Sync/src/net/ME1312/SubServers/Sync/Network/SubProtocol.java b/SubServers.Sync/src/net/ME1312/SubServers/Sync/Network/SubProtocol.java index 995f0689..5a8e2e43 100644 --- a/SubServers.Sync/src/net/ME1312/SubServers/Sync/Network/SubProtocol.java +++ b/SubServers.Sync/src/net/ME1312/SubServers/Sync/Network/SubProtocol.java @@ -182,7 +182,7 @@ public class SubProtocol extends SubDataProtocol { plugin.merge(server); } - plugin.api.getGlobalPlayers(players -> { + plugin.api.getRemotePlayers(players -> { for (RemotePlayer player : players.values()) { plugin.rPlayerLinkP.put(player.getUniqueId(), player.getProxy().toLowerCase()); plugin.rPlayers.put(player.getUniqueId(), new CachedPlayer(player)); diff --git a/SubServers.Sync/src/net/ME1312/SubServers/Sync/Server/ServerImpl.java b/SubServers.Sync/src/net/ME1312/SubServers/Sync/Server/ServerImpl.java index 294b5486..0378453c 100644 --- a/SubServers.Sync/src/net/ME1312/SubServers/Sync/Server/ServerImpl.java +++ b/SubServers.Sync/src/net/ME1312/SubServers/Sync/Server/ServerImpl.java @@ -118,14 +118,8 @@ public class ServerImpl extends BungeeServerInfo { * * @return Remote Player Collection */ - @SuppressWarnings("deprecation") - public Collection getGlobalPlayers() { - ExProxy plugin = SubAPI.getInstance().getInternals(); - ArrayList players = new ArrayList(); - for (UUID id : Util.getBackwards(plugin.rPlayerLinkS, this)) { - players.add(plugin.rPlayers.get(id)); - } - return players; + public Collection getRemotePlayers() { + return SubAPI.getInstance().getRemotePlayers(this).values(); } /** diff --git a/SubServers.Sync/src/net/ME1312/SubServers/Sync/SubAPI.java b/SubServers.Sync/src/net/ME1312/SubServers/Sync/SubAPI.java index c200fe53..2db93202 100644 --- a/SubServers.Sync/src/net/ME1312/SubServers/Sync/SubAPI.java +++ b/SubServers.Sync/src/net/ME1312/SubServers/Sync/SubAPI.java @@ -10,6 +10,8 @@ import net.ME1312.SubServers.Bungee.BungeeAPI; import net.ME1312.SubServers.Client.Common.ClientAPI; import net.ME1312.SubData.Client.SubDataClient; import net.ME1312.SubServers.Sync.Server.CachedPlayer; +import net.ME1312.SubServers.Sync.Server.ServerImpl; +import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.protocol.ProtocolConstants; import java.lang.reflect.InvocationTargetException; @@ -72,12 +74,38 @@ public final class SubAPI extends ClientAPI implements BungeeAPI { return name; } + /** + * Get the number of players on this network across all known proxies + * + * @return Remote Player Count + */ + public int getRemotePlayerCount() { + return plugin.rPlayers.size(); + } + + /** + * Get players on this server across all known proxies (Cached) + * + * @param server Server to search + * @return Remote Player Map + */ + public Map getRemotePlayers(ServerInfo server) { + if (server instanceof ServerImpl) { + HashMap players = new HashMap(); + for (UUID id : Util.getBackwards(plugin.rPlayerLinkS, (ServerImpl) server)) + players.put(id, plugin.rPlayers.get(id)); + return players; + } else { + return new HashMap<>(); + } + } + /** * Gets players on this network across all known proxies (Cached) * - * @return Remote Player Collection + * @return Remote Player Map */ - public Map getGlobalPlayers() { + public Map getRemotePlayers() { return new HashMap(plugin.rPlayers); } @@ -87,9 +115,9 @@ public final class SubAPI extends ClientAPI implements BungeeAPI { * @param name Player name * @return Remote Player */ - public CachedPlayer getGlobalPlayer(String name) { + public CachedPlayer getRemotePlayer(String name) { if (Util.isNull(name)) throw new NullPointerException(); - for (CachedPlayer player : getGlobalPlayers().values()) { + for (CachedPlayer player : getRemotePlayers().values()) { if (player.getName().equalsIgnoreCase(name)) return player; } return null; @@ -101,9 +129,9 @@ public final class SubAPI extends ClientAPI implements BungeeAPI { * @param id Player UUID * @return Remote Player */ - public CachedPlayer getGlobalPlayer(UUID id) { + public CachedPlayer getRemotePlayer(UUID id) { if (Util.isNull(id)) throw new NullPointerException(); - return getGlobalPlayers().getOrDefault(id, null); + return getRemotePlayers().getOrDefault(id, null); } /** diff --git a/SubServers.Sync/src/net/ME1312/SubServers/Sync/SubCommand.java b/SubServers.Sync/src/net/ME1312/SubServers/Sync/SubCommand.java index a67f1dcc..be25a125 100644 --- a/SubServers.Sync/src/net/ME1312/SubServers/Sync/SubCommand.java +++ b/SubServers.Sync/src/net/ME1312/SubServers/Sync/SubCommand.java @@ -222,7 +222,7 @@ public final class SubCommand extends CommandX { String type = (args.length > 2)?args[1]:null; String name = args[(type != null)?2:1]; - Runnable getPlayer = () -> plugin.api.getGlobalPlayer(name, player -> { + Runnable getPlayer = () -> plugin.api.getRemotePlayer(name, player -> { if (player != null) { sender.sendMessage("SubServers > Info on player: " + ChatColor.WHITE + player.getName()); if (player.getProxy() != null) sender.sendMessage(" -> Proxy: " + ChatColor.WHITE + player.getProxy()); @@ -254,7 +254,7 @@ public final class SubCommand extends CommandX { if (server instanceof SubServer) sender.sendMessage(" -> " + ((((SubServer) server).isOnline())?"Online":"Running") + ": " + ((((SubServer) server).isRunning())?ChatColor.GREEN+"yes":ChatColor.RED+"no")); if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) { sender.sendMessage(" -> Connected: " + ((server.getSubData()[0] != null)?ChatColor.GREEN+"yes"+((server.getSubData().length > 1)?ChatColor.AQUA+" +"+(server.getSubData().length-1)+" subchannel"+((server.getSubData().length == 2)?"":"s"):""):ChatColor.RED+"no")); - sender.sendMessage(" -> Players: " + ChatColor.AQUA + server.getGlobalPlayers().size() + " online"); + sender.sendMessage(" -> Players: " + ChatColor.AQUA + server.getRemotePlayers().size() + " online"); } sender.sendMessage(" -> MOTD: " + ChatColor.WHITE + ChatColor.stripColor(server.getMotd())); if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(" -> Stop Action: " + ChatColor.WHITE + ((SubServer) server).getStopAction().toString()); @@ -1007,7 +1007,7 @@ public final class SubCommand extends CommandX { ReturnRunnable> getPlayers = () -> { LinkedList names = new LinkedList(); for (ProxiedPlayer player : plugin.getPlayers()) names.add(player.getName()); - for (CachedPlayer player : plugin.api.getGlobalPlayers().values()) if (!names.contains(player.getName())) names.add(player.getName()); + for (CachedPlayer player : plugin.api.getRemotePlayers().values()) if (!names.contains(player.getName())) names.add(player.getName()); Collections.sort(names); return names; }; @@ -1215,7 +1215,7 @@ public final class SubCommand extends CommandX { } if (((ProxiedPlayer) sender).getServer().getInfo() instanceof ServerImpl) { - for (CachedPlayer player : ((ServerImpl) ((ProxiedPlayer) sender).getServer().getInfo()).getGlobalPlayers()) { + for (CachedPlayer player : ((ServerImpl) ((ProxiedPlayer) sender).getServer().getInfo()).getRemotePlayers()) { if (!used.contains(player.getUniqueId())) { if (player.getName().toLowerCase().startsWith(last)) list.add(Last + player.getName().substring(last.length())); used.add(player.getUniqueId()); @@ -1474,7 +1474,7 @@ public final class SubCommand extends CommandX { if (i != 0) serverm.addExtra(div); TextComponent message = new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.List").replace("$str$", server.getDisplayName())); try { - message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.Hover").replace("$int$", Integer.toString(server.getGlobalPlayers().size())))})); + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.Hover").replace("$int$", Integer.toString(server.getRemotePlayers().size())))})); } catch (Exception e) { e.printStackTrace(); } @@ -1555,7 +1555,7 @@ public final class SubCommand extends CommandX { int players = 0; for (ServerImpl server : plugin.servers.values()) { List playerlist = new ArrayList(); - for (CachedPlayer player : server.getGlobalPlayers()) playerlist.add(player.getName()); + for (CachedPlayer player : server.getRemotePlayers()) playerlist.add(player.getName()); Collections.sort(playerlist); players += playerlist.size();