Standardize RemotePlayer

This is the RemotePlayer API, not the GlobalPlayer API.
This commit is contained in:
ME1312 2020-11-14 13:12:08 -05:00
parent 20ab75530a
commit 4cfe1b4285
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
25 changed files with 189 additions and 91 deletions

View File

@ -5,6 +5,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version; import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Bungee.Library.Compatibility.RemotePlayer; import net.ME1312.SubServers.Bungee.Library.Compatibility.RemotePlayer;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import java.util.*; import java.util.*;
@ -35,16 +36,22 @@ public interface BungeeAPI {
* *
* @return Remote Player Collection * @return Remote Player Collection
*/ */
default int getRemotePlayerCount() { int getRemotePlayerCount();
return getGlobalPlayers().size();
} /**
* Get players on this server across all known proxies
*
* @param server Server to search
* @return Remote Player Map
*/
Map<UUID, ? extends RemotePlayer> getRemotePlayers(ServerInfo server);
/** /**
* Get players on this network across all known proxies * Get players on this network across all known proxies
* *
* @return Remote Player Collection * @return Remote Player Map
*/ */
Map<UUID, ? extends RemotePlayer> getGlobalPlayers(); Map<UUID, ? extends RemotePlayer> getRemotePlayers();
/** /**
* Get a player on this network by searching across all known proxies * Get a player on this network by searching across all known proxies
@ -52,7 +59,7 @@ public interface BungeeAPI {
* @param name Player name * @param name Player name
* @return Remote Player * @return Remote Player
*/ */
RemotePlayer getGlobalPlayer(String name); RemotePlayer getRemotePlayer(String name);
/** /**
* Get a player on this network by searching across all known proxies * Get a player on this network by searching across all known proxies
@ -60,7 +67,7 @@ public interface BungeeAPI {
* @param id Player UUID * @param id Player UUID
* @return Remote Player * @return Remote Player
*/ */
RemotePlayer getGlobalPlayer(UUID id); RemotePlayer getRemotePlayer(UUID id);
/** /**
* Gets the current SubServers Lang Channels * Gets the current SubServers Lang Channels

View File

@ -127,10 +127,10 @@ public abstract class Host implements ExtraDataHandler {
* *
* @return Remote Player Collection * @return Remote Player Collection
*/ */
public Collection<RemotePlayer> getGlobalPlayers() { public Collection<RemotePlayer> getRemotePlayers() {
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>(); LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
for (SubServer server : getSubServers().values()) { for (SubServer server : getSubServers().values()) {
players.addAll(server.getGlobalPlayers()); players.addAll(server.getRemotePlayers());
} }
return players; return players;
} }

View File

@ -63,7 +63,7 @@ public interface Server extends ServerInfo, ClientHandler, ExtraDataHandler {
* *
* @return Remote Player Collection * @return Remote Player Collection
*/ */
Collection<RemotePlayer> getGlobalPlayers(); Collection<RemotePlayer> getRemotePlayers();
/** /**
* If the server is hidden from players * If the server is hidden from players

View File

@ -158,15 +158,9 @@ public class ServerImpl extends BungeeServerInfo implements Server {
Collections.sort(groups); Collections.sort(groups);
} }
@SuppressWarnings("deprecation")
@Override @Override
public Collection<RemotePlayer> getGlobalPlayers() { public Collection<RemotePlayer> getRemotePlayers() {
SubProxy plugin = SubAPI.getInstance().getInternals(); return SubAPI.getInstance().getRemotePlayers(this).values();
ArrayList<RemotePlayer> players = new ArrayList<RemotePlayer>();
for (UUID id : Util.getBackwards(plugin.rPlayerLinkS, this)) {
players.add(plugin.rPlayers.get(id));
}
return players;
} }
@Override @Override
@ -286,7 +280,7 @@ public class ServerImpl extends BungeeServerInfo implements Server {
info.set("restricted", isRestricted()); info.set("restricted", isRestricted());
info.set("hidden", isHidden()); info.set("hidden", isHidden());
ObjectMap<String> players = new ObjectMap<String>(); ObjectMap<String> players = new ObjectMap<String>();
for (RemotePlayer player : getGlobalPlayers()) for (RemotePlayer player : getRemotePlayers())
players.set(player.getUniqueId().toString(), player.getName()); players.set(player.getUniqueId().toString(), player.getName());
info.set("players", players); info.set("players", players);
ObjectMap<Integer> subdata = new ObjectMap<Integer>(); ObjectMap<Integer> subdata = new ObjectMap<Integer>();

View File

@ -66,7 +66,7 @@ public class PacketDisconnectPlayer implements PacketObjectIn<Integer>, PacketOb
local.disconnect(); local.disconnect();
} }
client.sendPacket(new PacketDisconnectPlayer(0, tracker)); 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) { if (remote.getProxy().getSubData()[0] != null) {
((SubDataClient) remote.getProxy().getSubData()[0]).sendPacket(new PacketExDisconnectPlayer(remote.getUniqueId(), (data.contains(0x0002)?data.getRawString(0x0002):null), r -> { ((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)); client.sendPacket(new PacketDisconnectPlayer(r.getInt(0x0001), tracker));

View File

@ -70,7 +70,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
LinkedList<String> mcversions = new LinkedList<String>(); LinkedList<String> mcversions = new LinkedList<String>();
for (Version version : plugin.api.getGameVersion()) mcversions.add(version.toString()); for (Version version : plugin.api.getGameVersion()) mcversions.add(version.toString());
minecraft.set("version", mcversions); minecraft.set("version", mcversions);
minecraft.set("players", plugin.api.getGlobalPlayers().size()); minecraft.set("players", plugin.api.getRemotePlayers().size());
info.set("minecraft", minecraft); info.set("minecraft", minecraft);
ObjectMap<String> system = new ObjectMap<String>(); ObjectMap<String> system = new ObjectMap<String>();
ObjectMap<String> os = new ObjectMap<String>(); ObjectMap<String> os = new ObjectMap<String>();

View File

@ -61,16 +61,16 @@ public class PacketDownloadPlayerInfo implements PacketObjectIn<Integer>, Packet
ObjectMap<String> players = new ObjectMap<String>(); ObjectMap<String> players = new ObjectMap<String>();
if (ids == null && names == null) { 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()); players.set(player.getUniqueId().toString(), player.forSubData());
} }
} else { } else {
if (ids != null) for (UUID id : ids) { 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 (player != null) players.set(player.getUniqueId().toString(), player.forSubData());
} }
if (names != null) for (String name : names) { 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()); if (player != null) players.set(player.getUniqueId().toString(), player.forSubData());
} }
} }

View File

@ -15,6 +15,7 @@ import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util; import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version; import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException; import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.ProtocolConstants;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -544,12 +545,38 @@ public final class SubAPI implements BungeeAPI {
return plugin.mProxy; 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<UUID, RemotePlayer> getRemotePlayers(ServerInfo server) {
if (server instanceof Server) {
HashMap<UUID, RemotePlayer> players = new HashMap<UUID, RemotePlayer>();
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 * Get players on this network across all known proxies
* *
* @return Remote Player Collection * @return Remote Player Map
*/ */
public Map<UUID, RemotePlayer> getGlobalPlayers() { public Map<UUID, RemotePlayer> getRemotePlayers() {
return new HashMap<UUID, RemotePlayer>(plugin.rPlayers); return new HashMap<UUID, RemotePlayer>(plugin.rPlayers);
} }
@ -559,9 +586,9 @@ public final class SubAPI implements BungeeAPI {
* @param name Player name * @param name Player name
* @return Remote Player * @return Remote Player
*/ */
public RemotePlayer getGlobalPlayer(String name) { public RemotePlayer getRemotePlayer(String name) {
if (Util.isNull(name)) throw new NullPointerException(); if (Util.isNull(name)) throw new NullPointerException();
for (RemotePlayer player : getGlobalPlayers().values()) { for (RemotePlayer player : getRemotePlayers().values()) {
if (player.getName().equalsIgnoreCase(name)) return player; if (player.getName().equalsIgnoreCase(name)) return player;
} }
return null; return null;
@ -573,9 +600,9 @@ public final class SubAPI implements BungeeAPI {
* @param id Player UUID * @param id Player UUID
* @return Remote Player * @return Remote Player
*/ */
public RemotePlayer getGlobalPlayer(UUID id) { public RemotePlayer getRemotePlayer(UUID id) {
if (Util.isNull(id)) throw new NullPointerException(); if (Util.isNull(id)) throw new NullPointerException();
return getGlobalPlayers().getOrDefault(id, null); return getRemotePlayers().getOrDefault(id, null);
} }
/** /**

View File

@ -267,7 +267,7 @@ public final class SubCommand extends CommandX {
String name = args[(type != null)?2:1]; String name = args[(type != null)?2:1];
Runnable getPlayer = () -> { Runnable getPlayer = () -> {
RemotePlayer player = plugin.api.getGlobalPlayer(name); RemotePlayer player = plugin.api.getRemotePlayer(name);
if (player != null) { if (player != null) {
sender.sendMessage("SubServers > Info on player: " + ChatColor.WHITE + player.getName()); sender.sendMessage("SubServers > Info on player: " + ChatColor.WHITE + player.getName());
if (player.getProxy() != null) sender.sendMessage(" -> Proxy: " + ChatColor.WHITE + player.getProxy().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) sender.sendMessage(" -> " + ((((SubServer) server).isOnline())?"Online":"Running") + ": " + ((((SubServer) server).isRunning())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) { 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(" -> 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())); 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()); 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<Collection<String>> getPlayers = () -> { ReturnRunnable<Collection<String>> getPlayers = () -> {
LinkedList<String> names = new LinkedList<String>(); LinkedList<String> names = new LinkedList<String>();
for (ProxiedPlayer player : plugin.getPlayers()) names.add(player.getName()); 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); Collections.sort(names);
return names; return names;
}; };
@ -1109,7 +1109,7 @@ public final class SubCommand extends CommandX {
} }
if (((ProxiedPlayer) sender).getServer().getInfo() instanceof Server) { 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 (!used.contains(player.getUniqueId())) {
if (player.getName().toLowerCase().startsWith(last)) list.add(Last + player.getName().substring(last.length())); if (player.getName().toLowerCase().startsWith(last)) list.add(Last + player.getName().substring(last.length()));
used.add(player.getUniqueId()); used.add(player.getUniqueId());
@ -1186,7 +1186,7 @@ public final class SubCommand extends CommandX {
if (i != 0) serverm.addExtra(div); if (i != 0) serverm.addExtra(div);
TextComponent message = new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.List").replace("$str$", server.getDisplayName())); TextComponent message = new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.List").replace("$str$", server.getDisplayName()));
try { 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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -1259,7 +1259,7 @@ public final class SubCommand extends CommandX {
int players = 0; int players = 0;
for (Server server : plugin.api.getServers().values()) { for (Server server : plugin.api.getServers().values()) {
List<String> playerlist = new ArrayList<String>(); List<String> playerlist = new ArrayList<String>();
for (RemotePlayer player : server.getGlobalPlayers()) playerlist.add(player.getName()); for (RemotePlayer player : server.getRemotePlayers()) playerlist.add(player.getName());
Collections.sort(playerlist); Collections.sort(playerlist);
players += playerlist.size(); players += playerlist.size();

View File

@ -841,7 +841,7 @@ public class DefaultUIRenderer extends UIRenderer {
if (!server.getName().equals(server.getDisplayName())) if (!server.getName().equals(server.getDisplayName()))
lore.add(ChatColor.GRAY + server.getName()); 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-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(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()); lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
blockMeta.setLore(lore); blockMeta.setLore(lore);
@ -856,7 +856,7 @@ public class DefaultUIRenderer extends UIRenderer {
blockMeta.setDisplayName(ChatColor.AQUA + server.getDisplayName()); blockMeta.setDisplayName(ChatColor.AQUA + server.getDisplayName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary")); lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
} else blockMeta.setDisplayName(ChatColor.GREEN + server.getDisplayName()); } 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()); lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
blockMeta.setLore(lore); blockMeta.setLore(lore);
} else if (((SubServer) server).isAvailable() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) { } 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()); blockMeta.setDisplayName(ChatColor.AQUA + subserver.getDisplayName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary")); lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
} else blockMeta.setDisplayName(ChatColor.GREEN + subserver.getDisplayName()); } 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()); lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
blockMeta.setLore(lore); blockMeta.setLore(lore);
} else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) { } else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {

View File

@ -62,7 +62,7 @@ public class BungeeChat {
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary") + '\n'); hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary") + '\n');
hoverm.add(hover); 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) { } else if (((SubServer) server).isAvailable() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
message.setColor(ChatColor.YELLOW); message.setColor(ChatColor.YELLOW);
hover.setColor(ChatColor.YELLOW); hover.setColor(ChatColor.YELLOW);
@ -115,7 +115,7 @@ public class BungeeChat {
hoverm.add(hover); hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External") + '\n'); hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External") + '\n');
hoverm.add(hover); 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); hoverm.add(hover);
if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) { if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + server.getAddress().getAddress().getHostAddress() + ':' + server.getAddress().getPort()); 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'); hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary") + '\n');
hoverm.add(hover); 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) { } else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
message.setColor(ChatColor.YELLOW); message.setColor(ChatColor.YELLOW);
hover.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'); hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External") + '\n');
hoverm.add(hover); 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); hoverm.add(hover);
if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) { if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort()); hover = new TextComponent('\n' + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort());

View File

@ -474,7 +474,7 @@ public class PlaceholderImpl extends PlaceholderExpansion implements Taskable, C
return Integer.toString(host.getSubServers().size()); return Integer.toString(host.getSubServers().size());
} }
case "host.players": { case "host.players": {
return Integer.toString(host.getGlobalPlayers().size()); return Integer.toString(host.getRemotePlayers().size());
} }
case "host.subdata": { 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)]; 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 "server.players":
case "subserver.players": { case "subserver.players": {
return Integer.toString(server.getGlobalPlayers().size()); return Integer.toString(server.getRemotePlayers().size());
} }
case "server.subdata": case "server.subdata":
case "subserver.subdata": { case "subserver.subdata": {

View File

@ -197,7 +197,7 @@ public final class SubCommand extends BukkitCommand {
String type = (args.length > 2)?args[1]:null; String type = (args.length > 2)?args[1]:null;
String name = args[(type != null)?2:1]; String name = args[(type != null)?2:1];
Runnable getPlayer = () -> plugin.api.getGlobalPlayer(name, player -> { Runnable getPlayer = () -> plugin.api.getRemotePlayer(name, player -> {
if (player != null) { if (player != null) {
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info").replace("$str$", "player") + ChatColor.WHITE + player.getName()); 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()); 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) 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()) { 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$", "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())); 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()); 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());

View File

@ -52,6 +52,54 @@
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<finalName>SubServers.Client.Common</finalName>
<outputDirectory>../../Artifacts/Modulized</outputDirectory>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>javadoc</goal>
</goals>
<configuration>
<windowtitle>SubServers.Client.Common Javadoc</windowtitle>
<doctitle>SubServers.Client.Common Javadoc</doctitle>
<show>protected</show>
<destDir>./</destDir>
<outputDirectory>${basedir}/../../Javadoc/SubServers.Client.Common</outputDirectory>
<reportOutputDirectory>${basedir}/../../Javadoc/SubServers.Client.Common</reportOutputDirectory>
<additionalOptions>-Xdoclint:none</additionalOptions>
<links>
<link>https://dev.me1312.net/jenkins/job/GalaxiEngine/javadoc/GalaxiUtil/</link>
<link>https://dev.me1312.net/jenkins/job/SubData/javadoc/Client/</link>
</links>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -324,8 +324,8 @@ public abstract class ClientAPI {
* *
* @param callback Remote Player Collection * @param callback Remote Player Collection
*/ */
public void getGlobalPlayers(Callback<Map<UUID, RemotePlayer>> callback) { public void getRemotePlayers(Callback<Map<UUID, RemotePlayer>> callback) {
requestGlobalPlayers(null, callback); requestRemotePlayers(null, callback);
} }
/** /**
@ -334,8 +334,8 @@ public abstract class ClientAPI {
* @param name Player name * @param name Player name
* @param callback Remote Player * @param callback Remote Player
*/ */
public void getGlobalPlayer(String name, Callback<RemotePlayer> callback) { public void getRemotePlayer(String name, Callback<RemotePlayer> callback) {
requestGlobalPlayer(null, name, callback); requestRemotePlayer(null, name, callback);
} }
/** /**
@ -344,8 +344,8 @@ public abstract class ClientAPI {
* @param id Player UUID * @param id Player UUID
* @param callback Remote Player * @param callback Remote Player
*/ */
public void getGlobalPlayer(UUID id, Callback<RemotePlayer> callback) { public void getRemotePlayer(UUID id, Callback<RemotePlayer> callback) {
requestGlobalPlayer(null, id, callback); requestRemotePlayer(null, id, callback);
} }
/** /**

View File

@ -161,7 +161,7 @@ public class Host {
* *
* @return Remote Player Collection * @return Remote Player Collection
*/ */
public Collection<Pair<String, UUID>> getGlobalPlayers() { public Collection<Pair<String, UUID>> getRemotePlayers() {
List<Pair<String, UUID>> players = new ArrayList<Pair<String, UUID>>(); List<Pair<String, UUID>> players = new ArrayList<Pair<String, UUID>>();
for (String id : raw.getMap("players").getKeys()) { for (String id : raw.getMap("players").getKeys()) {
players.add(new ContainedPair<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id))); players.add(new ContainedPair<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id)));
@ -174,7 +174,7 @@ public class Host {
* *
* @param callback Remote Player Collection * @param callback Remote Player Collection
*/ */
public void getGlobalPlayers(Callback<Collection<RemotePlayer>> callback) { public void getRemotePlayers(Callback<Collection<RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException(); if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace(); StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> { Runnable run = () -> {
@ -189,7 +189,7 @@ public class Host {
if (players == null) { if (players == null) {
LinkedList<UUID> ids = new LinkedList<UUID>(); LinkedList<UUID> ids = new LinkedList<UUID>();
for (SubServer server : getSubServers().values()) for (Pair<String, UUID> player : server.getGlobalPlayers()) ids.add(player.value()); for (SubServer server : getSubServers().values()) for (Pair<String, UUID> player : server.getRemotePlayers()) ids.add(player.value());
client().sendPacket(new PacketDownloadPlayerInfo(ids, data -> { client().sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>(); LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
for (String player : data.getKeys()) { for (String player : data.getKeys()) {

View File

@ -125,7 +125,7 @@ public class Server {
* *
* @return Remote Player Collection * @return Remote Player Collection
*/ */
public Collection<Pair<String, UUID>> getGlobalPlayers() { public Collection<Pair<String, UUID>> getRemotePlayers() {
List<Pair<String, UUID>> players = new ArrayList<Pair<String, UUID>>(); List<Pair<String, UUID>> players = new ArrayList<Pair<String, UUID>>();
for (String id : raw.getMap("players").getKeys()) { for (String id : raw.getMap("players").getKeys()) {
players.add(new ContainedPair<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id))); players.add(new ContainedPair<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id)));
@ -138,7 +138,7 @@ public class Server {
* *
* @param callback Remote Player Collection * @param callback Remote Player Collection
*/ */
public void getGlobalPlayers(Callback<Collection<RemotePlayer>> callback) { public void getRemotePlayers(Callback<Collection<RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException(); if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace(); StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> { Runnable run = () -> {

View File

@ -328,7 +328,7 @@ public final class SimplifiedData {
* @param client SubData connection * @param client SubData connection
* @param callback Remote Player Collection * @param callback Remote Player Collection
*/ */
public static void requestGlobalPlayers(DataClient client, Callback<Map<UUID, RemotePlayer>> callback) { public static void requestRemotePlayers(DataClient client, Callback<Map<UUID, RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException(); if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace(); StackTraceElement[] origin = new Exception().getStackTrace();
client(client).sendPacket(new PacketDownloadPlayerInfo((List<UUID>) null, data -> { client(client).sendPacket(new PacketDownloadPlayerInfo((List<UUID>) null, data -> {
@ -354,7 +354,7 @@ public final class SimplifiedData {
* @param name Player name * @param name Player name
* @param callback Remote Player * @param callback Remote Player
*/ */
public static void requestGlobalPlayer(DataClient client, String name, Callback<RemotePlayer> callback) { public static void requestRemotePlayer(DataClient client, String name, Callback<RemotePlayer> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException(); if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace(); StackTraceElement[] origin = new Exception().getStackTrace();
client(client).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(name), data -> { client(client).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(name), data -> {
@ -380,7 +380,7 @@ public final class SimplifiedData {
* @param id Player UUID * @param id Player UUID
* @param callback Remote Player * @param callback Remote Player
*/ */
public static void requestGlobalPlayer(DataClient client, UUID id, Callback<RemotePlayer> callback) { public static void requestRemotePlayer(DataClient client, UUID id, Callback<RemotePlayer> callback) {
if (Util.isNull(id, callback)) throw new NullPointerException(); if (Util.isNull(id, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace(); StackTraceElement[] origin = new Exception().getStackTrace();
client(client).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(id), data -> { client(client).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(id), data -> {

View File

@ -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.SubServer-Temporary") + '\n'));
} }
hover.append( 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) { } else if (((SubServer) server).isAvailable() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
message.color(TextColors.YELLOW); message.color(TextColors.YELLOW);
@ -292,7 +292,7 @@ public final class SubCommand implements CommandExecutor {
} }
hover.append( hover.append(
ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-External") + '\n'), 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)) { 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()); 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.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.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) { } else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
message.color(TextColors.YELLOW); message.color(TextColors.YELLOW);
hover.color(TextColors.YELLOW); hover.color(TextColors.YELLOW);
@ -409,7 +409,7 @@ public final class SubCommand implements CommandExecutor {
} }
hover.append( hover.append(
ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-External") + '\n'), 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)) { 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()); hover.append(Text.builder('\n' + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort()).color(TextColors.WHITE).build());
} else { } else {
@ -488,7 +488,7 @@ public final class SubCommand implements CommandExecutor {
String name = n.get(); String name = n.get();
Runnable getPlayer = () -> plugin.api.getGlobalPlayer(name, player -> { Runnable getPlayer = () -> plugin.api.getRemotePlayer(name, player -> {
if (player != null) { 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()); 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()); 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) 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()) { 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$", "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()); 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()); 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());

View File

@ -7,5 +7,5 @@
<version>-PLACEHOLDER</version> <version>-PLACEHOLDER</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<!-- This module is a placeholder; it has no real maven artifacts. --> <!-- This module is a placeholder. It has no real maven artifacts. -->
</project> </project>

View File

@ -187,7 +187,7 @@ public class SubCommand {
String type = (args.length > 1)?args[0]:null; String type = (args.length > 1)?args[0]:null;
String name = args[(type != null)?1:0]; String name = args[(type != null)?1:0];
Runnable getPlayer = () -> host.api.getGlobalPlayer(name, player -> { Runnable getPlayer = () -> host.api.getRemotePlayer(name, player -> {
if (player != null) { if (player != null) {
sender.sendMessage("Info on player: " + TextColor.WHITE + player.getName()); sender.sendMessage("Info on player: " + TextColor.WHITE + player.getName());
if (player.getProxy() != null) sender.sendMessage(" -> Proxy: " + TextColor.WHITE + player.getProxy()); 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) sender.sendMessage(" -> " + ((((SubServer) server).isOnline())?"Online":"Running") + ": " + ((((SubServer) server).isRunning())?TextColor.GREEN+"yes":TextColor.RED+"no"));
if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) { 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(" -> 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())); 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()); if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(" -> Stop Action: " + TextColor.WHITE + ((SubServer) server).getStopAction().toString());

View File

@ -182,7 +182,7 @@ public class SubProtocol extends SubDataProtocol {
plugin.merge(server); plugin.merge(server);
} }
plugin.api.getGlobalPlayers(players -> { plugin.api.getRemotePlayers(players -> {
for (RemotePlayer player : players.values()) { for (RemotePlayer player : players.values()) {
plugin.rPlayerLinkP.put(player.getUniqueId(), player.getProxy().toLowerCase()); plugin.rPlayerLinkP.put(player.getUniqueId(), player.getProxy().toLowerCase());
plugin.rPlayers.put(player.getUniqueId(), new CachedPlayer(player)); plugin.rPlayers.put(player.getUniqueId(), new CachedPlayer(player));

View File

@ -118,14 +118,8 @@ public class ServerImpl extends BungeeServerInfo {
* *
* @return Remote Player Collection * @return Remote Player Collection
*/ */
@SuppressWarnings("deprecation") public Collection<CachedPlayer> getRemotePlayers() {
public Collection<CachedPlayer> getGlobalPlayers() { return SubAPI.getInstance().getRemotePlayers(this).values();
ExProxy plugin = SubAPI.getInstance().getInternals();
ArrayList<CachedPlayer> players = new ArrayList<CachedPlayer>();
for (UUID id : Util.getBackwards(plugin.rPlayerLinkS, this)) {
players.add(plugin.rPlayers.get(id));
}
return players;
} }
/** /**

View File

@ -10,6 +10,8 @@ import net.ME1312.SubServers.Bungee.BungeeAPI;
import net.ME1312.SubServers.Client.Common.ClientAPI; import net.ME1312.SubServers.Client.Common.ClientAPI;
import net.ME1312.SubData.Client.SubDataClient; import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Sync.Server.CachedPlayer; 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 net.md_5.bungee.protocol.ProtocolConstants;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -72,12 +74,38 @@ public final class SubAPI extends ClientAPI implements BungeeAPI {
return name; 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<UUID, CachedPlayer> getRemotePlayers(ServerInfo server) {
if (server instanceof ServerImpl) {
HashMap<UUID, CachedPlayer> players = new HashMap<UUID, CachedPlayer>();
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) * Gets players on this network across all known proxies (Cached)
* *
* @return Remote Player Collection * @return Remote Player Map
*/ */
public Map<UUID, CachedPlayer> getGlobalPlayers() { public Map<UUID, CachedPlayer> getRemotePlayers() {
return new HashMap<UUID, CachedPlayer>(plugin.rPlayers); return new HashMap<UUID, CachedPlayer>(plugin.rPlayers);
} }
@ -87,9 +115,9 @@ public final class SubAPI extends ClientAPI implements BungeeAPI {
* @param name Player name * @param name Player name
* @return Remote Player * @return Remote Player
*/ */
public CachedPlayer getGlobalPlayer(String name) { public CachedPlayer getRemotePlayer(String name) {
if (Util.isNull(name)) throw new NullPointerException(); if (Util.isNull(name)) throw new NullPointerException();
for (CachedPlayer player : getGlobalPlayers().values()) { for (CachedPlayer player : getRemotePlayers().values()) {
if (player.getName().equalsIgnoreCase(name)) return player; if (player.getName().equalsIgnoreCase(name)) return player;
} }
return null; return null;
@ -101,9 +129,9 @@ public final class SubAPI extends ClientAPI implements BungeeAPI {
* @param id Player UUID * @param id Player UUID
* @return Remote Player * @return Remote Player
*/ */
public CachedPlayer getGlobalPlayer(UUID id) { public CachedPlayer getRemotePlayer(UUID id) {
if (Util.isNull(id)) throw new NullPointerException(); if (Util.isNull(id)) throw new NullPointerException();
return getGlobalPlayers().getOrDefault(id, null); return getRemotePlayers().getOrDefault(id, null);
} }
/** /**

View File

@ -222,7 +222,7 @@ public final class SubCommand extends CommandX {
String type = (args.length > 2)?args[1]:null; String type = (args.length > 2)?args[1]:null;
String name = args[(type != null)?2:1]; String name = args[(type != null)?2:1];
Runnable getPlayer = () -> plugin.api.getGlobalPlayer(name, player -> { Runnable getPlayer = () -> plugin.api.getRemotePlayer(name, player -> {
if (player != null) { if (player != null) {
sender.sendMessage("SubServers > Info on player: " + ChatColor.WHITE + player.getName()); sender.sendMessage("SubServers > Info on player: " + ChatColor.WHITE + player.getName());
if (player.getProxy() != null) sender.sendMessage(" -> Proxy: " + ChatColor.WHITE + player.getProxy()); 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) sender.sendMessage(" -> " + ((((SubServer) server).isOnline())?"Online":"Running") + ": " + ((((SubServer) server).isRunning())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) { 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(" -> 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())); 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()); 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<Collection<String>> getPlayers = () -> { ReturnRunnable<Collection<String>> getPlayers = () -> {
LinkedList<String> names = new LinkedList<String>(); LinkedList<String> names = new LinkedList<String>();
for (ProxiedPlayer player : plugin.getPlayers()) names.add(player.getName()); 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); Collections.sort(names);
return names; return names;
}; };
@ -1215,7 +1215,7 @@ public final class SubCommand extends CommandX {
} }
if (((ProxiedPlayer) sender).getServer().getInfo() instanceof ServerImpl) { 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 (!used.contains(player.getUniqueId())) {
if (player.getName().toLowerCase().startsWith(last)) list.add(Last + player.getName().substring(last.length())); if (player.getName().toLowerCase().startsWith(last)) list.add(Last + player.getName().substring(last.length()));
used.add(player.getUniqueId()); used.add(player.getUniqueId());
@ -1474,7 +1474,7 @@ public final class SubCommand extends CommandX {
if (i != 0) serverm.addExtra(div); if (i != 0) serverm.addExtra(div);
TextComponent message = new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.List").replace("$str$", server.getDisplayName())); TextComponent message = new TextComponent(plugin.api.getLang("SubServers", "Bungee.Server.List").replace("$str$", server.getDisplayName()));
try { 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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -1555,7 +1555,7 @@ public final class SubCommand extends CommandX {
int players = 0; int players = 0;
for (ServerImpl server : plugin.servers.values()) { for (ServerImpl server : plugin.servers.values()) {
List<String> playerlist = new ArrayList<String>(); List<String> playerlist = new ArrayList<String>();
for (CachedPlayer player : server.getGlobalPlayers()) playerlist.add(player.getName()); for (CachedPlayer player : server.getRemotePlayers()) playerlist.add(player.getName());
Collections.sort(playerlist); Collections.sort(playerlist);
players += playerlist.size(); players += playerlist.size();