mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-22 02:08:27 +01:00
Fix constructor overrides
This commit is contained in:
parent
1fff679005
commit
0a6fdb337f
@ -1,7 +1,6 @@
|
||||
package net.ME1312.SubServers.Client.Common.Network.API;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Callback.Callback;
|
||||
import net.ME1312.Galaxi.Library.Container.ContainedPair;
|
||||
import net.ME1312.Galaxi.Library.Container.Pair;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
|
||||
@ -197,7 +196,7 @@ public class Host {
|
||||
client().sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
|
||||
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
|
||||
for (String player : data.getKeys()) {
|
||||
players.add(RemotePlayer.st4tic.construct(servers.get(UUID.fromString(player)), data.getMap(player)));
|
||||
players.add(RemotePlayer.instance.construct(servers.get(UUID.fromString(player)), data.getMap(player)));
|
||||
}
|
||||
|
||||
this.players = players;
|
||||
|
@ -10,7 +10,6 @@ import net.ME1312.SubData.Client.DataClient;
|
||||
import net.ME1312.SubData.Client.DataSender;
|
||||
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
import net.ME1312.SubServers.Client.Common.ClientAPI;
|
||||
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketDownloadPlayerInfo;
|
||||
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketDownloadProxyInfo;
|
||||
@ -149,7 +148,7 @@ public class Proxy {
|
||||
client().sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
|
||||
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
|
||||
for (String player : data.getKeys()) {
|
||||
players.add(RemotePlayer.st4tic.construct(this, data.getMap(player)));
|
||||
players.add(RemotePlayer.instance.construct(this, data.getMap(player)));
|
||||
}
|
||||
|
||||
this.players = players;
|
||||
|
@ -16,7 +16,7 @@ import java.util.*;
|
||||
* Simplified RemotePlayer Data Class
|
||||
*/
|
||||
public class RemotePlayer {
|
||||
protected static StaticImpl st4tic = new StaticImpl();
|
||||
protected static StaticImpl instance = new StaticImpl();
|
||||
ObjectMap<String> raw;
|
||||
private Proxy proxy = null;
|
||||
private Server server = null;
|
||||
@ -223,7 +223,7 @@ public class RemotePlayer {
|
||||
* @param response Success Status
|
||||
*/
|
||||
public void sendMessage(String[] messages, Callback<Integer> response) {
|
||||
st4tic.sendMessage(client(), new UUID[]{ getUniqueId() }, messages, response);
|
||||
instance.sendMessage(client(), new UUID[]{ getUniqueId() }, messages, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,7 +255,7 @@ public class RemotePlayer {
|
||||
* @param response Success Status
|
||||
*/
|
||||
public static void sendMessage(UUID[] players, String[] messages, Callback<Integer> response) {
|
||||
st4tic.sendMessage(SimplifiedData.client(ClientAPI.getInstance().getSubDataNetwork()[0]), players, messages, response);
|
||||
instance.sendMessage(SimplifiedData.client(ClientAPI.getInstance().getSubDataNetwork()[0]), players, messages, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -313,7 +313,7 @@ public class RemotePlayer {
|
||||
* @param response Success Status
|
||||
*/
|
||||
public void sendRawMessage(String[] message, Callback<Integer> response) {
|
||||
st4tic.sendRawMessage(client(), new UUID[]{ getUniqueId() }, message, response);
|
||||
instance.sendRawMessage(client(), new UUID[]{ getUniqueId() }, message, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -345,7 +345,7 @@ public class RemotePlayer {
|
||||
* @param response Success Status
|
||||
*/
|
||||
public static void sendRawMessage(UUID[] players, String[] messages, Callback<Integer> response) {
|
||||
st4tic.sendRawMessage(SimplifiedData.client(ClientAPI.getInstance().getSubDataNetwork()[0]), players, messages, response);
|
||||
instance.sendRawMessage(SimplifiedData.client(ClientAPI.getInstance().getSubDataNetwork()[0]), players, messages, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,7 +364,7 @@ public class RemotePlayer {
|
||||
* @param response Success status
|
||||
*/
|
||||
public void transfer(String server, Callback<Integer> response) {
|
||||
st4tic.transfer(client(), new UUID[]{ getUniqueId() }, server, response);
|
||||
instance.transfer(client(), new UUID[]{ getUniqueId() }, server, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -385,7 +385,7 @@ public class RemotePlayer {
|
||||
* @param response Success status
|
||||
*/
|
||||
public static void transfer(UUID[] players, String server, Callback<Integer> response) {
|
||||
st4tic.transfer(SimplifiedData.client(ClientAPI.getInstance().getSubDataNetwork()[0]), players, server, response);
|
||||
instance.transfer(SimplifiedData.client(ClientAPI.getInstance().getSubDataNetwork()[0]), players, server, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -420,7 +420,7 @@ public class RemotePlayer {
|
||||
* @param response Success status
|
||||
*/
|
||||
public void disconnect(String reason, Callback<Integer> response) {
|
||||
st4tic.disconnect(client(), new UUID[]{ getUniqueId() }, reason, response);
|
||||
instance.disconnect(client(), new UUID[]{ getUniqueId() }, reason, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -460,7 +460,7 @@ public class RemotePlayer {
|
||||
* @param response Success status
|
||||
*/
|
||||
public static void disconnect(UUID[] players, String reason, Callback<Integer> response) {
|
||||
st4tic.disconnect(SimplifiedData.client(ClientAPI.getInstance().getSubDataNetwork()[0]), players, reason, response);
|
||||
instance.disconnect(SimplifiedData.client(ClientAPI.getInstance().getSubDataNetwork()[0]), players, reason, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -511,7 +511,7 @@ public class RemotePlayer {
|
||||
* @param raw Raw representation of the Remote Player
|
||||
*/
|
||||
final RemotePlayer construct(Server server, ObjectMap<String> raw) {
|
||||
RemotePlayer player = new RemotePlayer(server.client, raw);
|
||||
RemotePlayer player = construct(server.client, raw);
|
||||
player.server = server;
|
||||
return player;
|
||||
}
|
||||
@ -523,7 +523,7 @@ public class RemotePlayer {
|
||||
* @param raw Raw representation of the Remote Player
|
||||
*/
|
||||
final RemotePlayer construct(Proxy proxy, ObjectMap<String> raw) {
|
||||
RemotePlayer player = new RemotePlayer(proxy.client, raw);
|
||||
RemotePlayer player = construct(proxy.client, raw);
|
||||
player.proxy = proxy;
|
||||
return player;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import net.ME1312.SubData.Client.DataClient;
|
||||
import net.ME1312.SubData.Client.DataSender;
|
||||
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
import net.ME1312.SubServers.Client.Common.ClientAPI;
|
||||
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketDownloadPlayerInfo;
|
||||
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketDownloadServerInfo;
|
||||
@ -157,7 +156,7 @@ public class Server {
|
||||
client().sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
|
||||
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
|
||||
for (String player : data.getKeys()) {
|
||||
players.add(RemotePlayer.st4tic.construct(this, data.getMap(player)));
|
||||
players.add(RemotePlayer.instance.construct(this, data.getMap(player)));
|
||||
}
|
||||
|
||||
this.players = players;
|
||||
|
@ -334,7 +334,7 @@ public final class SimplifiedData {
|
||||
client(client).sendPacket(new PacketDownloadPlayerInfo((List<UUID>) null, data -> {
|
||||
TreeMap<UUID, RemotePlayer> players = new TreeMap<UUID, RemotePlayer>();
|
||||
for (String player : data.getKeys()) {
|
||||
players.put(UUID.fromString(player), RemotePlayer.st4tic.construct(client, data.getMap(player)));
|
||||
players.put(UUID.fromString(player), RemotePlayer.instance.construct(client, data.getMap(player)));
|
||||
}
|
||||
|
||||
try {
|
||||
@ -360,7 +360,7 @@ public final class SimplifiedData {
|
||||
client(client).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(name), data -> {
|
||||
RemotePlayer player = null;
|
||||
if (data.getKeys().size() > 0) {
|
||||
player = RemotePlayer.st4tic.construct(client, data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
|
||||
player = RemotePlayer.instance.construct(client, data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
|
||||
}
|
||||
|
||||
try {
|
||||
@ -386,7 +386,7 @@ public final class SimplifiedData {
|
||||
client(client).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(id), data -> {
|
||||
RemotePlayer player = null;
|
||||
if (data.getKeys().size() > 0) {
|
||||
player = RemotePlayer.st4tic.construct(client, data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
|
||||
player = RemotePlayer.instance.construct(client, data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -107,7 +107,7 @@ public class CachedPlayer extends RemotePlayer implements net.ME1312.SubServers.
|
||||
}
|
||||
};
|
||||
// These overrides prevent sending unnecessary packets in ClientCommon
|
||||
st4tic = new StaticImpl() {
|
||||
instance = new StaticImpl() {
|
||||
@Override
|
||||
protected RemotePlayer construct(DataClient client, ObjectMap<String> raw) {
|
||||
return new CachedPlayer(client, raw);
|
||||
@ -168,54 +168,46 @@ public class CachedPlayer extends RemotePlayer implements net.ME1312.SubServers.
|
||||
|
||||
@Override
|
||||
protected void transfer(SubDataClient client, UUID[] players, String server, Callback<Integer> response) {
|
||||
if (players != null && players.length > 0) {
|
||||
ArrayList<UUID> ids = new ArrayList<UUID>();
|
||||
ServerImpl info = SubAPI.getInstance().getInternals().servers.get(server.toLowerCase());
|
||||
int failures = 0;
|
||||
for (UUID id : players) {
|
||||
ProxiedPlayer local = get(id);
|
||||
if (local != null) {
|
||||
if (info != null) {
|
||||
local.connect(info);
|
||||
} else ++failures;
|
||||
} else {
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (ids.size() == 0) {
|
||||
response.run(failures);
|
||||
ArrayList<UUID> ids = new ArrayList<UUID>();
|
||||
ServerImpl info = SubAPI.getInstance().getInternals().servers.get(server.toLowerCase());
|
||||
int failures = 0;
|
||||
for (UUID id : players) {
|
||||
ProxiedPlayer local = get(id);
|
||||
if (local != null) {
|
||||
if (info != null) {
|
||||
local.connect(info);
|
||||
} else ++failures;
|
||||
} else {
|
||||
final int ff = failures;
|
||||
super.transfer(client, ids.toArray(new UUID[0]), server, i -> response.run(i + ff));
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (ids.size() == 0) {
|
||||
response.run(failures);
|
||||
} else {
|
||||
super.transfer(client, players, server, response);
|
||||
final int ff = failures;
|
||||
super.transfer(client, ids.toArray(new UUID[0]), server, i -> response.run(i + ff));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disconnect(SubDataClient client, UUID[] players, String reason, Callback<Integer> response) {
|
||||
if (players != null && players.length > 0) {
|
||||
ArrayList<UUID> ids = new ArrayList<UUID>();
|
||||
for (UUID id : players) {
|
||||
ProxiedPlayer local = get(id);
|
||||
if (local != null) {
|
||||
if (reason != null) {
|
||||
local.disconnect(reason);
|
||||
} else local.disconnect();
|
||||
} else {
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (ids.size() == 0) {
|
||||
response.run(0);
|
||||
ArrayList<UUID> ids = new ArrayList<UUID>();
|
||||
for (UUID id : players) {
|
||||
ProxiedPlayer local = get(id);
|
||||
if (local != null) {
|
||||
if (reason != null) {
|
||||
local.disconnect(reason);
|
||||
} else local.disconnect();
|
||||
} else {
|
||||
super.disconnect(client, ids.toArray(new UUID[0]), reason, response);
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (ids.size() == 0) {
|
||||
response.run(0);
|
||||
} else {
|
||||
super.disconnect(client, players, reason, response);
|
||||
super.disconnect(client, ids.toArray(new UUID[0]), reason, response);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user