Disallow the same UUID to make multiple connections to a multi-proxy network

This commit is contained in:
ME1312 2020-08-12 20:18:55 -04:00
parent 83041a1f3f
commit b18f047d53
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
5 changed files with 56 additions and 39 deletions

View File

@ -80,7 +80,7 @@ public final class SubProxy extends BungeeCord implements Listener {
public SubProtocol subprotocol;
public SubDataServer subdata = null;
public SubServer sudo = null;
public static final Version version = Version.fromString("2.16.1a");
public static final Version version = Version.fromString("2.16.2a");
public final Proxy mProxy;
public boolean canSudo = false;
@ -802,8 +802,9 @@ public final class SubProxy extends BungeeCord implements Listener {
@EventHandler(priority = Byte.MIN_VALUE)
public void ping_passthrough(ProxyPingEvent e) {
boolean dynamic;
ServerInfo override;
if (SmartFallback.getForcedHost(e.getConnection()) == null && (override = SmartFallback.getDNS(e.getConnection())) != null) {
if ((dynamic = SmartFallback.getForcedHost(e.getConnection()) == null) && getReconnectHandler() instanceof SmartFallback && (override = SmartFallback.getDNS(e.getConnection())) != null) {
if (!(override instanceof SubServer) || ((SubServer) override).isRunning()) {
if (!e.getConnection().getListener().isPingPassthrough()) {
e.setResponse(new ServerPing(e.getResponse().getVersion(), e.getResponse().getPlayers(), new TextComponent(override.getMotd()), null));
@ -818,14 +819,15 @@ public final class SubProxy extends BungeeCord implements Listener {
while (lock.value) Util.isException(() -> Thread.sleep(4));
}
}
} else if (dynamic) {
e.getResponse().getPlayers().setOnline(rPlayers.size());
}
}
@EventHandler(priority = Byte.MAX_VALUE)
public void ping(ProxyPingEvent e) {
boolean forced;
ServerInfo override;
if ((forced = (override = SmartFallback.getForcedHost(e.getConnection())) != null) || (override = SmartFallback.getDNS(e.getConnection())) != null) {
if ((override = SmartFallback.getForcedHost(e.getConnection())) != null || (override = SmartFallback.getDNS(e.getConnection())) != null) {
if (override instanceof SubServer && !((SubServer) override).isRunning()) {
e.setResponse(new ServerPing(e.getResponse().getVersion(), e.getResponse().getPlayers(), new TextComponent(api.getLang("SubServers", "Bungee.Ping.Offline")), null));
}
@ -843,6 +845,14 @@ public final class SubProxy extends BungeeCord implements Listener {
}
}
@EventHandler(priority = Byte.MIN_VALUE)
public void login(LoginEvent e) {
if (rPlayers.containsKey(e.getConnection().getUniqueId())) {
e.setCancelled(true);
e.setCancelReason(new TextComponent(getTranslation("already_connected_proxy")));
}
}
@EventHandler(priority = Byte.MAX_VALUE)
public void validate(ServerConnectEvent e) {
Map<String, ServerInfo> servers = new TreeMap<String, ServerInfo>(api.getServers());
@ -885,7 +895,7 @@ public final class SubProxy extends BungeeCord implements Listener {
@SuppressWarnings("deprecation")
@EventHandler(priority = Byte.MAX_VALUE)
public void setPlayer(ServerConnectedEvent e) {
public void connected(ServerConnectedEvent e) {
RemotePlayer player = new RemotePlayer(e.getPlayer().getName(), e.getPlayer().getUniqueId(), mProxy, (e.getServer().getInfo() instanceof Server)?(Server) e.getServer().getInfo():null, e.getPlayer().getAddress());
rPlayers.put(player.getUniqueId(), player);
rPlayerLinkP.put(player.getUniqueId(), player.getProxy());
@ -894,6 +904,16 @@ public final class SubProxy extends BungeeCord implements Listener {
((SubDataClient) proxy.getSubData()[0]).sendPacket(new PacketExSyncPlayer(mProxy.getName(), true, player));
}
if (fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) new Timer("SubServers.Bungee::Fallback_Limbo_Timer(" + e.getPlayer().getUniqueId() + ')').schedule(new TimerTask() {
@Override
public void run() {
if (e.getPlayer().getServer() != null && !((UserConnection) e.getPlayer()).isDimensionChange() && e.getPlayer().getServer().getInfo().getAddress().equals(e.getServer().getInfo().getAddress())) {
fallbackLimbo.remove(e.getPlayer().getUniqueId());
e.getPlayer().sendMessage(api.getLang("SubServers", "Bungee.Feature.Smart-Fallback.Result").replace("$str$", (e.getServer().getInfo() instanceof Server)?((Server) e.getServer().getInfo()).getDisplayName():e.getServer().getInfo().getName()));
}
}
}, 1000);
}
@SuppressWarnings("deprecation")
@ -923,19 +943,7 @@ public final class SubProxy extends BungeeCord implements Listener {
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = Byte.MAX_VALUE)
public void fallbackFound(ServerConnectedEvent e) {
if (fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) new Timer("SubServers.Bungee::Fallback_Limbo_Timer(" + e.getPlayer().getUniqueId() + ')').schedule(new TimerTask() {
@Override
public void run() {
if (e.getPlayer().getServer() != null && !((UserConnection) e.getPlayer()).isDimensionChange() && e.getPlayer().getServer().getInfo().getAddress().equals(e.getServer().getInfo().getAddress())) {
fallbackLimbo.remove(e.getPlayer().getUniqueId());
e.getPlayer().sendMessage(api.getLang("SubServers", "Bungee.Feature.Smart-Fallback.Result").replace("$str$", (e.getServer().getInfo() instanceof Server)?((Server) e.getServer().getInfo()).getDisplayName():e.getServer().getInfo().getName()));
}
}
}, 1000);
}
@EventHandler(priority = Byte.MIN_VALUE)
public void resetPlayer(PlayerDisconnectEvent e) {
fallbackLimbo.remove(e.getPlayer().getUniqueId());

View File

@ -1,6 +1,6 @@
name: SubServers-Client-Bukkit
main: net.ME1312.SubServers.Client.Bukkit.SubPlugin
version: "2.16.1a"
version: "2.16.2a"
authors: ["ME1312"]
softdepend: [TitleManager, PlaceholderAPI]
website: "https://github.com/ME1312/SubServers-2"

View File

@ -46,7 +46,7 @@ import java.util.concurrent.TimeUnit;
/**
* SubServers Client Plugin Class
*/
@Plugin(id = "subservers-client-sponge", name = "SubServers-Client-Sponge", authors = "ME1312", version = "2.16.1a", url = "https://github.com/ME1312/SubServers-2", description = "Take control of the server manager — from your servers")
@Plugin(id = "subservers-client-sponge", name = "SubServers-Client-Sponge", authors = "ME1312", version = "2.16.2a", url = "https://github.com/ME1312/SubServers-2", description = "Take control of the server manager — from your servers")
public final class SubPlugin {
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
NamedContainer<Long, Map<String, Map<String, String>>> lang = null;

View File

@ -42,7 +42,7 @@ import java.util.jar.Manifest;
/**
* SubServers.Host Main Class
*/
@App(name = "SubServers.Host", version = "2.16.1a", authors = "ME1312", website = "https://github.com/ME1312/SubServers-2", description = "Host subservers on separate machines")
@App(name = "SubServers.Host", version = "2.16.2a", authors = "ME1312", website = "https://github.com/ME1312/SubServers-2", description = "Host subservers on separate machines")
public final class ExHost {
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
NamedContainer<Long, Map<String, Map<String, String>>> lang = null;

View File

@ -66,7 +66,7 @@ public final class ExProxy extends BungeeCord implements Listener {
public YAMLConfig config;
public final SubAPI api = new SubAPI(this);
public SubProtocol subprotocol;
public static final Version version = Version.fromString("2.16.1a");
public static final Version version = Version.fromString("2.16.2a");
public final boolean isPatched;
public final boolean isGalaxi;
@ -327,8 +327,9 @@ public final class ExProxy extends BungeeCord implements Listener {
@EventHandler(priority = Byte.MIN_VALUE)
public void ping_passthrough(ProxyPingEvent e) {
boolean dynamic;
ServerInfo override;
if (SmartFallback.getForcedHost(e.getConnection()) == null && (override = SmartFallback.getDNS(e.getConnection())) != null) {
if ((dynamic = SmartFallback.getForcedHost(e.getConnection()) == null) && getReconnectHandler() instanceof SmartFallback && (override = SmartFallback.getDNS(e.getConnection())) != null) {
if (!(override instanceof SubServerImpl) || ((SubServerImpl) override).isRunning()) {
if (!e.getConnection().getListener().isPingPassthrough()) {
e.setResponse(new ServerPing(e.getResponse().getVersion(), e.getResponse().getPlayers(), new TextComponent(override.getMotd()), null));
@ -343,14 +344,15 @@ public final class ExProxy extends BungeeCord implements Listener {
while (lock.value) Util.isException(() -> Thread.sleep(4));
}
}
} else if (dynamic) {
e.getResponse().getPlayers().setOnline(rPlayers.size());
}
}
@EventHandler(priority = Byte.MAX_VALUE)
public void ping(ProxyPingEvent e) {
boolean forced;
ServerInfo override;
if ((forced = (override = SmartFallback.getForcedHost(e.getConnection())) != null) || (override = SmartFallback.getDNS(e.getConnection())) != null) {
if ((override = SmartFallback.getForcedHost(e.getConnection())) != null || (override = SmartFallback.getDNS(e.getConnection())) != null) {
if (override instanceof SubServerImpl && !((SubServerImpl) override).isRunning()) {
e.setResponse(new ServerPing(e.getResponse().getVersion(), e.getResponse().getPlayers(), new TextComponent(api.getLang("SubServers", "Bungee.Ping.Offline")), null));
}
@ -367,6 +369,14 @@ public final class ExProxy extends BungeeCord implements Listener {
}
}
@EventHandler(priority = Byte.MIN_VALUE)
public void login(LoginEvent e) {
if (rPlayers.containsKey(e.getConnection().getUniqueId())) {
e.setCancelled(true);
e.setCancelReason(new TextComponent(getTranslation("already_connected_proxy")));
}
}
@EventHandler(priority = Byte.MAX_VALUE)
public void validate(ServerConnectEvent e) {
Map<String, ServerInfo> servers = new TreeMap<String, ServerInfo>(this.servers);
@ -409,7 +419,7 @@ public final class ExProxy extends BungeeCord implements Listener {
@SuppressWarnings("deprecation")
@EventHandler(priority = Byte.MAX_VALUE)
public void setPlayer(ServerConnectedEvent e) {
public void connected(ServerConnectedEvent e) {
ObjectMap<String> raw = RemotePlayer.translate(e.getPlayer());
raw.set("server", e.getServer().getInfo().getName());
RemotePlayer player = new RemotePlayer(raw);
@ -419,6 +429,17 @@ public final class ExProxy extends BungeeCord implements Listener {
if (api.getSubDataNetwork()[0] != null) {
((SubDataClient) api.getSubDataNetwork()[0]).sendPacket(new PacketExSyncPlayer(true, player));
}
if (fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) new Timer("SubServers.Sync::Fallback_Limbo_Timer(" + e.getPlayer().getUniqueId() + ')').schedule(new TimerTask() {
@Override
public void run() {
if (e.getPlayer().getServer() != null && !((UserConnection) e.getPlayer()).isDimensionChange() && e.getPlayer().getServer().getInfo().getAddress().equals(e.getServer().getInfo().getAddress())) {
fallbackLimbo.remove(e.getPlayer().getUniqueId());
e.getPlayer().sendMessage(api.getLang("SubServers", "Bungee.Feature.Smart-Fallback.Result").replace("$str$", (e.getServer().getInfo() instanceof ServerImpl)?((ServerImpl) e.getServer().getInfo()).getDisplayName():e.getServer().getInfo().getName()));
}
}
}, 1000);
}
@SuppressWarnings("deprecation")
@ -448,19 +469,7 @@ public final class ExProxy extends BungeeCord implements Listener {
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = Byte.MAX_VALUE)
public void fallbackFound(ServerConnectedEvent e) {
if (fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) new Timer("SubServers.Sync::Fallback_Limbo_Timer(" + e.getPlayer().getUniqueId() + ')').schedule(new TimerTask() {
@Override
public void run() {
if (e.getPlayer().getServer() != null && !((UserConnection) e.getPlayer()).isDimensionChange() && e.getPlayer().getServer().getInfo().getAddress().equals(e.getServer().getInfo().getAddress())) {
fallbackLimbo.remove(e.getPlayer().getUniqueId());
e.getPlayer().sendMessage(api.getLang("SubServers", "Bungee.Feature.Smart-Fallback.Result").replace("$str$", (e.getServer().getInfo() instanceof ServerImpl)?((ServerImpl) e.getServer().getInfo()).getDisplayName():e.getServer().getInfo().getName()));
}
}
}, 1000);
}
@EventHandler(priority = Byte.MIN_VALUE)
public void resetPlayer(PlayerDisconnectEvent e) {
fallbackLimbo.remove(e.getPlayer().getUniqueId());