Assign a short-hand for getting player data

/sub info u ME1312
This commit is contained in:
ME1312 2021-10-21 21:31:59 -04:00
parent 5d3664cbc7
commit 16c373b336
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
9 changed files with 48 additions and 15 deletions

View File

@ -382,6 +382,8 @@ public final class SubCommand extends Command implements TabExecutor {
case "subserver": case "subserver":
getServer.run(); getServer.run();
break; break;
case "u":
case "user":
case "player": case "player":
getPlayer.run(); getPlayer.run();
break; break;

View File

@ -328,6 +328,8 @@ public final class SubCommand extends Command {
case "subserver": case "subserver":
getServer.run(); getServer.run();
break; break;
case "u":
case "user":
case "player": case "player":
getPlayer.run(); getPlayer.run();
break; break;

View File

@ -634,6 +634,8 @@ public final class SubCommand implements CommandExecutor {
case "subserver": case "subserver":
getServer.run(); getServer.run();
break; break;
case "u":
case "user":
case "player": case "player":
getPlayer.run(); getPlayer.run();
break; break;

View File

@ -317,6 +317,8 @@ public class SubCommand {
case "subserver": case "subserver":
getServer.run(); getServer.run();
break; break;
case "u":
case "user":
case "player": case "player":
getPlayer.run(); getPlayer.run();
break; break;

View File

@ -688,8 +688,7 @@ public final class ExProxy extends BungeeCommon implements Listener {
@EventHandler(priority = Byte.MIN_VALUE) @EventHandler(priority = Byte.MIN_VALUE)
public void remove(SubRemoveServerEvent e) { public void remove(SubRemoveServerEvent e) {
if (servers.keySet().contains(e.getServer().toLowerCase())) if (servers.remove(e.getServer().toLowerCase()) != null)
servers.remove(e.getServer().toLowerCase());
Logger.get("SubServers").info("Removed Server: " + e.getServer()); Logger.get("SubServers").info("Removed Server: " + e.getServer());
} }
} }

View File

@ -5,7 +5,6 @@ import net.ME1312.Galaxi.Library.Container.Pair;
import net.ME1312.Galaxi.Library.Map.ObjectMap; import net.ME1312.Galaxi.Library.Map.ObjectMap;
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.SubData.Client.Library.DataSize;
import net.ME1312.SubData.Client.SubDataClient; import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataProtocol; import net.ME1312.SubData.Client.SubDataProtocol;
import net.ME1312.SubServers.Client.Common.Network.API.RemotePlayer; import net.ME1312.SubServers.Client.Common.Network.API.RemotePlayer;
@ -13,6 +12,7 @@ import net.ME1312.SubServers.Client.Common.Network.API.Server;
import net.ME1312.SubServers.Client.Common.Network.Packet.*; import net.ME1312.SubServers.Client.Common.Network.Packet.*;
import net.ME1312.SubServers.Sync.Event.SubNetworkConnectEvent; import net.ME1312.SubServers.Sync.Event.SubNetworkConnectEvent;
import net.ME1312.SubServers.Sync.Event.SubNetworkDisconnectEvent; import net.ME1312.SubServers.Sync.Event.SubNetworkDisconnectEvent;
import net.ME1312.SubServers.Sync.Event.SubRemoveServerEvent;
import net.ME1312.SubServers.Sync.ExProxy; import net.ME1312.SubServers.Sync.ExProxy;
import net.ME1312.SubServers.Sync.Network.Packet.*; import net.ME1312.SubServers.Sync.Network.Packet.*;
import net.ME1312.SubServers.Sync.Server.CachedPlayer; import net.ME1312.SubServers.Sync.Server.CachedPlayer;
@ -192,18 +192,28 @@ public class SubProtocol extends SubDataProtocol {
subdata.sendPacket(new PacketExSyncPlayer(null, localPlayers.toArray(new CachedPlayer[0]))); subdata.sendPacket(new PacketExSyncPlayer(null, localPlayers.toArray(new CachedPlayer[0])));
plugin.api.getServers(servers -> { plugin.api.getServers(servers -> {
HashMap<String, ServerImpl> localServers = new HashMap<String, ServerImpl>(plugin.servers);
for (Server server : servers.values()) { for (Server server : servers.values()) {
localServers.remove(server.getName().toLowerCase());
plugin.merge(server); plugin.merge(server);
} }
for (ServerImpl server : localServers.values()) {
plugin.remove(new SubRemoveServerEvent(null, null, server.getName()));
}
plugin.api.getRemotePlayers(players -> { plugin.api.getRemotePlayers(players -> {
for (RemotePlayer player : players.values()) { synchronized (plugin.rPlayers) {
plugin.rPlayerLinkP.put(player.getUniqueId(), player.getProxyName().toLowerCase()); plugin.rPlayerLinkS.clear();
plugin.rPlayers.put(player.getUniqueId(), (CachedPlayer) player); plugin.rPlayerLinkP.clear();
plugin.rPlayers.clear();
for (RemotePlayer player : players.values()) {
plugin.rPlayerLinkP.put(player.getUniqueId(), player.getProxyName().toLowerCase());
plugin.rPlayers.put(player.getUniqueId(), (CachedPlayer) player);
ServerInfo server = plugin.getServerInfo(player.getServerName()); ServerInfo server = plugin.getServerInfo(player.getServerName());
if (server instanceof ServerImpl) if (server instanceof ServerImpl)
plugin.rPlayerLinkS.put(player.getUniqueId(), (ServerImpl) server); plugin.rPlayerLinkS.put(player.getUniqueId(), (ServerImpl) server);
}
} }
}); });
}); });

View File

@ -322,6 +322,8 @@ public final class SubCommand extends Command implements TabExecutor {
case "subserver": case "subserver":
getServer.run(); getServer.run();
break; break;
case "u":
case "user":
case "player": case "player":
getPlayer.run(); getPlayer.run();
break; break;

View File

@ -12,6 +12,7 @@ import net.ME1312.SubServers.Client.Common.Network.API.Server;
import net.ME1312.SubServers.Client.Common.Network.Packet.*; import net.ME1312.SubServers.Client.Common.Network.Packet.*;
import net.ME1312.SubServers.Velocity.Event.SubNetworkConnectEvent; import net.ME1312.SubServers.Velocity.Event.SubNetworkConnectEvent;
import net.ME1312.SubServers.Velocity.Event.SubNetworkDisconnectEvent; import net.ME1312.SubServers.Velocity.Event.SubNetworkDisconnectEvent;
import net.ME1312.SubServers.Velocity.Event.SubRemoveServerEvent;
import net.ME1312.SubServers.Velocity.ExProxy; import net.ME1312.SubServers.Velocity.ExProxy;
import net.ME1312.SubServers.Velocity.Network.Packet.*; import net.ME1312.SubServers.Velocity.Network.Packet.*;
import net.ME1312.SubServers.Velocity.Server.CachedPlayer; import net.ME1312.SubServers.Velocity.Server.CachedPlayer;
@ -20,6 +21,7 @@ import net.ME1312.SubServers.Velocity.SubAPI;
import com.velocitypowered.api.proxy.config.ProxyConfig; import com.velocitypowered.api.proxy.config.ProxyConfig;
import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -188,18 +190,28 @@ public class SubProtocol extends SubDataProtocol {
subdata.sendPacket(new PacketExSyncPlayer(null, localPlayers.toArray(new CachedPlayer[0]))); subdata.sendPacket(new PacketExSyncPlayer(null, localPlayers.toArray(new CachedPlayer[0])));
plugin.api.getServers(servers -> { plugin.api.getServers(servers -> {
ArrayList<ServerData> localServers = new ArrayList<ServerData>(plugin.servers.values());
for (Server server : servers.values()) { for (Server server : servers.values()) {
ExProxy.getInstance().getServer(server.getName()).map(RegisteredServer::getServerInfo).map(plugin::getData).ifPresent(localServers::remove);
plugin.merge(server); plugin.merge(server);
} }
for (ServerData server : localServers) {
plugin.remove(new SubRemoveServerEvent(null, null, server.getName()));
}
plugin.api.getRemotePlayers(players -> { plugin.api.getRemotePlayers(players -> {
for (RemotePlayer player : players.values()) { synchronized (plugin.rPlayers) {
plugin.rPlayerLinkP.put(player.getUniqueId(), player.getProxyName().toLowerCase()); plugin.rPlayerLinkS.clear();
plugin.rPlayers.put(player.getUniqueId(), (CachedPlayer) player); plugin.rPlayerLinkP.clear();
plugin.rPlayers.clear();
for (RemotePlayer player : players.values()) {
plugin.rPlayerLinkP.put(player.getUniqueId(), player.getProxyName().toLowerCase());
plugin.rPlayers.put(player.getUniqueId(), (CachedPlayer) player);
ExProxy.getInstance().getServer(player.getServerName()).map(RegisteredServer::getServerInfo).map(plugin::getData).ifPresent(server -> ExProxy.getInstance().getServer(player.getServerName()).map(RegisteredServer::getServerInfo).map(plugin::getData).ifPresent(server ->
plugin.rPlayerLinkS.put(player.getUniqueId(), server) plugin.rPlayerLinkS.put(player.getUniqueId(), server)
); );
}
} }
}); });
}); });

View File

@ -327,6 +327,8 @@ public final class SubCommand implements SimpleCommand {
case "subserver": case "subserver":
getServer.run(); getServer.run();
break; break;
case "u":
case "user":
case "player": case "player":
getPlayer.run(); getPlayer.run();
break; break;