mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-13 05:54:32 +01:00
Override fallback servers when using Reconnect
This commit is contained in:
parent
29dbd107c0
commit
0136419960
@ -90,7 +90,7 @@ public class InternalSubCreator extends SubCreator {
|
||||
Version version = this.version;
|
||||
HashMap<String, String> var = new HashMap<String, String>();
|
||||
boolean error = false;
|
||||
if (history.contains(template)) throw new IllegalStateException("Template Import loop detected");
|
||||
if (history.contains(template)) throw new IllegalStateException("Template import loop detected");
|
||||
history.add(template);
|
||||
for (String other : template.getBuildOptions().getStringList("Import", new ArrayList<String>())) {
|
||||
if (templates.keySet().contains(other.toLowerCase())) {
|
||||
@ -107,7 +107,7 @@ public class InternalSubCreator extends SubCreator {
|
||||
Logger.get(prefix).info("Skipping template that cannot be run in update mode: " + other);
|
||||
}
|
||||
} else {
|
||||
Logger.get(prefix).info("Skipping template that requires extra versioning: " + other);
|
||||
Logger.get(prefix).info("Skipping template that requires extra versioning information: " + other);
|
||||
}
|
||||
} else {
|
||||
Logger.get(prefix).info("Skipping disabled template: " + other);
|
||||
|
@ -33,22 +33,24 @@ public class SmartFallback implements ReconnectHandler {
|
||||
|
||||
@Override
|
||||
public ServerInfo getServer(ProxiedPlayer player) {
|
||||
ServerInfo override;
|
||||
if ((override = getForcedHost(player.getPendingConnection())) != null) {
|
||||
return override;
|
||||
} else if ((override = getDNS(player.getPendingConnection())) != null) {
|
||||
return override;
|
||||
} else if ((override = getReconnectServer(player)) != null) {
|
||||
return override;
|
||||
} else {
|
||||
Map<String, ServerInfo> fallbacks = getFallbackServers(player.getPendingConnection().getListener(), player);
|
||||
if (fallbacks.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
if (player instanceof UserConnection) ((UserConnection) player).setServerJoinQueue(new LinkedList<>(fallbacks.keySet()));
|
||||
return new LinkedList<Map.Entry<String, ServerInfo>>(fallbacks.entrySet()).getFirst().getValue();
|
||||
Map<String, ServerInfo> fallbacks = getFallbackServers(player.getPendingConnection().getListener(), player);
|
||||
LinkedList<String> queue = new LinkedList<String>(fallbacks.keySet());
|
||||
|
||||
ServerInfo server;
|
||||
if ((server = getForcedHost(player.getPendingConnection())) == null
|
||||
&& (server = getDNS(player.getPendingConnection())) == null
|
||||
&& (server = getReconnectServer(player)) == null) {
|
||||
if (!fallbacks.isEmpty()) {
|
||||
server = new LinkedList<ServerInfo>(fallbacks.values()).getFirst();
|
||||
}
|
||||
} else {
|
||||
queue.addFirst(server.getName());
|
||||
}
|
||||
|
||||
|
||||
if (server != null && player instanceof UserConnection)
|
||||
((UserConnection) player).setServerJoinQueue(new LinkedList<>(fallbacks.keySet()));
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,6 @@ import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.BungeeServerInfo;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@ -891,7 +890,7 @@ public final class SubProxy extends BungeeCord implements Listener {
|
||||
|
||||
@EventHandler(priority = Byte.MIN_VALUE)
|
||||
public void login(LoginEvent e) {
|
||||
ProxyServer.getInstance().getLogger().info("UUID of player " + e.getConnection().getName() + " is " + e.getConnection().getUniqueId());
|
||||
super.getLogger().info("UUID of player " + e.getConnection().getName() + " is " + e.getConnection().getUniqueId());
|
||||
if (rPlayers.containsKey(e.getConnection().getUniqueId())) {
|
||||
Logger.get("SubServers").warning(e.getConnection().getName() + " connected, but already had a database entry");
|
||||
RemotePlayer player = rPlayers.get(e.getConnection().getUniqueId());
|
||||
@ -906,73 +905,79 @@ public final class SubProxy extends BungeeCord implements Listener {
|
||||
|
||||
@EventHandler(priority = Byte.MAX_VALUE)
|
||||
public void validate(ServerConnectEvent e) {
|
||||
Map<String, ServerInfo> servers = new TreeMap<String, ServerInfo>(api.getServers());
|
||||
if (servers.keySet().contains(e.getTarget().getName().toLowerCase()) && e.getTarget() != servers.get(e.getTarget().getName().toLowerCase())) {
|
||||
e.setTarget(servers.get(e.getTarget().getName().toLowerCase()));
|
||||
} else {
|
||||
servers = getServersCopy();
|
||||
if (servers.keySet().contains(e.getTarget().getName()) && e.getTarget() != servers.get(e.getTarget().getName())) {
|
||||
e.setTarget(servers.get(e.getTarget().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!e.getTarget().canAccess(e.getPlayer())) {
|
||||
if (e.getPlayer().getServer() == null || fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
if (!fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId()) || fallbackLimbo.get(e.getPlayer().getUniqueId()).contains(e.getTarget())) {
|
||||
ServerKickEvent kick = new ServerKickEvent(e.getPlayer(), e.getTarget(), new BaseComponent[]{
|
||||
new TextComponent(getTranslation("no_server_permission"))
|
||||
}, null, ServerKickEvent.State.CONNECTING);
|
||||
fallback(kick);
|
||||
if (!kick.isCancelled()) e.getPlayer().disconnect(kick.getKickReasonComponent());
|
||||
if (e.getPlayer().getServer() != null) e.setCancelled(true);
|
||||
}
|
||||
if (e.getPlayer().isConnected()) {
|
||||
Map<String, ServerInfo> servers = new TreeMap<String, ServerInfo>(api.getServers());
|
||||
if (servers.keySet().contains(e.getTarget().getName().toLowerCase()) && e.getTarget() != servers.get(e.getTarget().getName().toLowerCase())) {
|
||||
e.setTarget(servers.get(e.getTarget().getName().toLowerCase()));
|
||||
} else {
|
||||
e.getPlayer().sendMessage(getTranslation("no_server_permission"));
|
||||
e.setCancelled(true);
|
||||
servers = getServersCopy();
|
||||
if (servers.keySet().contains(e.getTarget().getName()) && e.getTarget() != servers.get(e.getTarget().getName())) {
|
||||
e.setTarget(servers.get(e.getTarget().getName()));
|
||||
}
|
||||
}
|
||||
} else if (e.getPlayer().getServer() != null && !fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId()) && e.getTarget() instanceof SubServer && !((SubServer) e.getTarget()).isRunning()) {
|
||||
e.getPlayer().sendMessage(api.getLang("SubServers", "Bungee.Server.Offline"));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
if (fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
if (fallbackLimbo.get(e.getPlayer().getUniqueId()).contains(e.getTarget())) {
|
||||
fallbackLimbo.get(e.getPlayer().getUniqueId()).remove(e.getTarget());
|
||||
} else if (e.getPlayer().getServer() != null) {
|
||||
if (!e.getTarget().canAccess(e.getPlayer())) {
|
||||
if (e.getPlayer().getServer() == null || fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
if (!fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId()) || fallbackLimbo.get(e.getPlayer().getUniqueId()).contains(e.getTarget())) {
|
||||
ServerKickEvent kick = new ServerKickEvent(e.getPlayer(), e.getTarget(), new BaseComponent[]{
|
||||
new TextComponent(getTranslation("no_server_permission"))
|
||||
}, null, ServerKickEvent.State.CONNECTING);
|
||||
fallback(kick);
|
||||
if (!kick.isCancelled()) e.getPlayer().disconnect(kick.getKickReasonComponent());
|
||||
if (e.getPlayer().getServer() != null) e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
e.getPlayer().sendMessage(getTranslation("no_server_permission"));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if (e.getPlayer().getServer() != null && !fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId()) && e.getTarget() instanceof SubServer && !((SubServer) e.getTarget()).isRunning()) {
|
||||
e.getPlayer().sendMessage(api.getLang("SubServers", "Bungee.Server.Offline"));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
if (fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
if (fallbackLimbo.get(e.getPlayer().getUniqueId()).contains(e.getTarget())) {
|
||||
fallbackLimbo.get(e.getPlayer().getUniqueId()).remove(e.getTarget());
|
||||
} else if (e.getPlayer().getServer() != null) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = Byte.MAX_VALUE)
|
||||
public void connected(ServerConnectedEvent e) {
|
||||
synchronized (rPlayers) {
|
||||
RemotePlayer player = new RemotePlayer(e.getPlayer().getName(), e.getPlayer().getUniqueId(), mProxy, (e.getServer().getInfo() instanceof Server)?(Server) e.getServer().getInfo():null, e.getPlayer().getAddress());
|
||||
rPlayerLinkP.put(player.getUniqueId(), player.getProxy());
|
||||
rPlayers.put(player.getUniqueId(), player);
|
||||
if (player.getServer() != null) rPlayerLinkS.put(player.getUniqueId(), player.getServer());
|
||||
for (Proxy proxy : SubAPI.getInstance().getProxies().values()) if (proxy.getSubData()[0] != null) {
|
||||
((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()));
|
||||
if (e.getPlayer().isConnected()) {
|
||||
synchronized (rPlayers) {
|
||||
RemotePlayer player = new RemotePlayer(e.getPlayer().getName(), e.getPlayer().getUniqueId(), mProxy, (e.getServer().getInfo() instanceof Server)?(Server) e.getServer().getInfo():null, e.getPlayer().getAddress());
|
||||
rPlayerLinkP.put(player.getUniqueId(), player.getProxy());
|
||||
rPlayers.put(player.getUniqueId(), player);
|
||||
if (player.getServer() != null) rPlayerLinkS.put(player.getUniqueId(), player.getServer());
|
||||
for (Proxy proxy : SubAPI.getInstance().getProxies().values()) if (proxy.getSubData()[0] != null) {
|
||||
((SubDataClient) proxy.getSubData()[0]).sendPacket(new PacketExSyncPlayer(mProxy.getName(), true, player));
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
|
||||
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")
|
||||
@EventHandler(priority = Byte.MAX_VALUE)
|
||||
public void fallback(ServerKickEvent e) {
|
||||
if (e.getPlayer() instanceof UserConnection && config.get().getMap("Settings").getMap("Smart-Fallback", new ObjectMap<>()).getBoolean("Fallback", true)) {
|
||||
if (e.getPlayer().isConnected() && e.getPlayer() instanceof UserConnection && config.get().getMap("Settings").getMap("Smart-Fallback", new ObjectMap<>()).getBoolean("Fallback", true)) {
|
||||
Map<String, ServerInfo> fallbacks;
|
||||
if (!fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
fallbacks = SmartFallback.getFallbackServers(e.getPlayer().getPendingConnection().getListener(), e.getPlayer());
|
||||
@ -997,7 +1002,7 @@ public final class SubProxy extends BungeeCord implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = Byte.MIN_VALUE)
|
||||
@EventHandler(priority = Byte.MAX_VALUE)
|
||||
public void resetPlayer(PlayerDisconnectEvent e) {
|
||||
UUID id = e.getPlayer().getUniqueId();
|
||||
fallbackLimbo.remove(id);
|
||||
|
@ -266,7 +266,7 @@ public class SubCreatorImpl {
|
||||
Version version = this.version;
|
||||
HashMap<String, String> var = new HashMap<String, String>();
|
||||
boolean error = false;
|
||||
if (history.contains(template)) throw new IllegalStateException("Template Import loop detected");
|
||||
if (history.contains(template)) throw new IllegalStateException("Template import loop detected");
|
||||
history.add(template);
|
||||
for (String other : template.getBuildOptions().getStringList("Import", new ArrayList<String>())) {
|
||||
if (templates.keySet().contains(other.toLowerCase())) {
|
||||
@ -284,8 +284,8 @@ public class SubCreatorImpl {
|
||||
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketOutExLogMessage(address, "Skipping template that cannot be run in update mode: " + other));
|
||||
}
|
||||
} else {
|
||||
log.logger.warn.println("Skipping template that requires extra versioning: " + other);
|
||||
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketOutExLogMessage(address, "Skipping template that requires extra versioning: " + other));
|
||||
log.logger.warn.println("Skipping template that requires extra versioning information: " + other);
|
||||
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketOutExLogMessage(address, "Skipping template that requires extra versioning information: " + other));
|
||||
}
|
||||
} else {
|
||||
log.logger.warn.println("Skipping disabled template: " + other);
|
||||
|
@ -32,7 +32,6 @@ import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.BungeeServerInfo;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@ -424,7 +423,7 @@ public final class ExProxy extends BungeeCord implements Listener {
|
||||
|
||||
@EventHandler(priority = Byte.MIN_VALUE)
|
||||
public void login(LoginEvent e) {
|
||||
ProxyServer.getInstance().getLogger().info("UUID of player " + e.getConnection().getName() + " is " + e.getConnection().getUniqueId());
|
||||
super.getLogger().info("UUID of player " + e.getConnection().getName() + " is " + e.getConnection().getUniqueId());
|
||||
if (rPlayers.containsKey(e.getConnection().getUniqueId())) {
|
||||
Logger.get("SubServers").warning(e.getConnection().getName() + " connected, but already had a database entry");
|
||||
RemotePlayer player = rPlayers.get(e.getConnection().getUniqueId());
|
||||
@ -439,75 +438,81 @@ public final class ExProxy extends BungeeCord implements Listener {
|
||||
|
||||
@EventHandler(priority = Byte.MAX_VALUE)
|
||||
public void validate(ServerConnectEvent e) {
|
||||
Map<String, ServerInfo> servers = new TreeMap<String, ServerInfo>(this.servers);
|
||||
if (servers.keySet().contains(e.getTarget().getName().toLowerCase()) && e.getTarget() != servers.get(e.getTarget().getName().toLowerCase())) {
|
||||
e.setTarget(servers.get(e.getTarget().getName().toLowerCase()));
|
||||
} else {
|
||||
servers = getServers();
|
||||
if (servers.keySet().contains(e.getTarget().getName()) && e.getTarget() != servers.get(e.getTarget().getName())) {
|
||||
e.setTarget(servers.get(e.getTarget().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!e.getTarget().canAccess(e.getPlayer())) {
|
||||
if (e.getPlayer().getServer() == null || fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
if (!fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId()) || fallbackLimbo.get(e.getPlayer().getUniqueId()).contains(e.getTarget())) {
|
||||
ServerKickEvent kick = new ServerKickEvent(e.getPlayer(), e.getTarget(), new BaseComponent[]{
|
||||
new TextComponent(getTranslation("no_server_permission"))
|
||||
}, null, ServerKickEvent.State.CONNECTING);
|
||||
fallback(kick);
|
||||
if (!kick.isCancelled()) e.getPlayer().disconnect(kick.getKickReasonComponent());
|
||||
if (e.getPlayer().getServer() != null) e.setCancelled(true);
|
||||
}
|
||||
if (e.getPlayer().isConnected()) {
|
||||
Map<String, ServerInfo> servers = new TreeMap<String, ServerInfo>(this.servers);
|
||||
if (servers.keySet().contains(e.getTarget().getName().toLowerCase()) && e.getTarget() != servers.get(e.getTarget().getName().toLowerCase())) {
|
||||
e.setTarget(servers.get(e.getTarget().getName().toLowerCase()));
|
||||
} else {
|
||||
e.getPlayer().sendMessage(getTranslation("no_server_permission"));
|
||||
e.setCancelled(true);
|
||||
servers = getServers();
|
||||
if (servers.keySet().contains(e.getTarget().getName()) && e.getTarget() != servers.get(e.getTarget().getName())) {
|
||||
e.setTarget(servers.get(e.getTarget().getName()));
|
||||
}
|
||||
}
|
||||
} else if (e.getPlayer().getServer() != null && !fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId()) && e.getTarget() instanceof SubServerImpl && !((SubServerImpl) e.getTarget()).isRunning()) {
|
||||
e.getPlayer().sendMessage(api.getLang("SubServers", "Bungee.Server.Offline"));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
if (fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
if (fallbackLimbo.get(e.getPlayer().getUniqueId()).contains(e.getTarget())) {
|
||||
fallbackLimbo.get(e.getPlayer().getUniqueId()).remove(e.getTarget());
|
||||
} else if (e.getPlayer().getServer() != null) {
|
||||
if (!e.getTarget().canAccess(e.getPlayer())) {
|
||||
if (e.getPlayer().getServer() == null || fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
if (!fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId()) || fallbackLimbo.get(e.getPlayer().getUniqueId()).contains(e.getTarget())) {
|
||||
ServerKickEvent kick = new ServerKickEvent(e.getPlayer(), e.getTarget(), new BaseComponent[]{
|
||||
new TextComponent(getTranslation("no_server_permission"))
|
||||
}, null, ServerKickEvent.State.CONNECTING);
|
||||
fallback(kick);
|
||||
if (!kick.isCancelled()) e.getPlayer().disconnect(kick.getKickReasonComponent());
|
||||
if (e.getPlayer().getServer() != null) e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
e.getPlayer().sendMessage(getTranslation("no_server_permission"));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if (e.getPlayer().getServer() != null && !fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId()) && e.getTarget() instanceof SubServerImpl && !((SubServerImpl) e.getTarget()).isRunning()) {
|
||||
e.getPlayer().sendMessage(api.getLang("SubServers", "Bungee.Server.Offline"));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
if (fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
if (fallbackLimbo.get(e.getPlayer().getUniqueId()).contains(e.getTarget())) {
|
||||
fallbackLimbo.get(e.getPlayer().getUniqueId()).remove(e.getTarget());
|
||||
} else if (e.getPlayer().getServer() != null) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = Byte.MAX_VALUE)
|
||||
public void connected(ServerConnectedEvent e) {
|
||||
synchronized (rPlayers) {
|
||||
ObjectMap<String> raw = RemotePlayer.translate(e.getPlayer());
|
||||
raw.set("server", e.getServer().getInfo().getName());
|
||||
RemotePlayer player = new RemotePlayer(raw);
|
||||
rPlayerLinkP.put(player.getUniqueId(), player.getProxy().toLowerCase());
|
||||
rPlayers.put(player.getUniqueId(), player);
|
||||
if (e.getServer().getInfo() instanceof ServerImpl) rPlayerLinkS.put(player.getUniqueId(), (ServerImpl) e.getServer().getInfo());
|
||||
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()));
|
||||
if (e.getPlayer().isConnected()) {
|
||||
synchronized (rPlayers) {
|
||||
ObjectMap<String> raw = RemotePlayer.translate(e.getPlayer());
|
||||
raw.set("server", e.getServer().getInfo().getName());
|
||||
RemotePlayer player = new RemotePlayer(raw);
|
||||
rPlayerLinkP.put(player.getUniqueId(), player.getProxy().toLowerCase());
|
||||
rPlayers.put(player.getUniqueId(), player);
|
||||
if (e.getServer().getInfo() instanceof ServerImpl) rPlayerLinkS.put(player.getUniqueId(), (ServerImpl) e.getServer().getInfo());
|
||||
if (api.getSubDataNetwork()[0] != null) {
|
||||
((SubDataClient) api.getSubDataNetwork()[0]).sendPacket(new PacketExSyncPlayer(true, player));
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
|
||||
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")
|
||||
@EventHandler(priority = Byte.MAX_VALUE)
|
||||
public void fallback(ServerKickEvent e) {
|
||||
if (e.getPlayer() instanceof UserConnection && config.get().getMap("Settings").getMap("Smart-Fallback", new ObjectMap<>()).getBoolean("Fallback", true)) {
|
||||
if (e.getPlayer().isConnected() && e.getPlayer() instanceof UserConnection && config.get().getMap("Settings").getMap("Smart-Fallback", new ObjectMap<>()).getBoolean("Fallback", true)) {
|
||||
Map<String, ServerInfo> fallbacks;
|
||||
if (!fallbackLimbo.keySet().contains(e.getPlayer().getUniqueId())) {
|
||||
fallbacks = SmartFallback.getFallbackServers(e.getPlayer().getPendingConnection().getListener(), e.getPlayer());
|
||||
@ -532,7 +537,7 @@ public final class ExProxy extends BungeeCord implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = Byte.MIN_VALUE)
|
||||
@EventHandler(priority = Byte.MAX_VALUE)
|
||||
public void resetPlayer(PlayerDisconnectEvent e) {
|
||||
UUID id = e.getPlayer().getUniqueId();
|
||||
fallbackLimbo.remove(id);
|
||||
|
@ -33,22 +33,24 @@ public class SmartFallback implements ReconnectHandler {
|
||||
|
||||
@Override
|
||||
public ServerInfo getServer(ProxiedPlayer player) {
|
||||
ServerInfo override;
|
||||
if ((override = getForcedHost(player.getPendingConnection())) != null) {
|
||||
return override;
|
||||
} else if ((override = getDNS(player.getPendingConnection())) != null) {
|
||||
return override;
|
||||
} else if ((override = getReconnectServer(player)) != null) {
|
||||
return override;
|
||||
} else {
|
||||
Map<String, ServerInfo> fallbacks = getFallbackServers(player.getPendingConnection().getListener(), player);
|
||||
if (fallbacks.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
if (player instanceof UserConnection) ((UserConnection) player).setServerJoinQueue(new LinkedList<>(fallbacks.keySet()));
|
||||
return new LinkedList<Map.Entry<String, ServerInfo>>(fallbacks.entrySet()).getFirst().getValue();
|
||||
Map<String, ServerInfo> fallbacks = getFallbackServers(player.getPendingConnection().getListener(), player);
|
||||
LinkedList<String> queue = new LinkedList<String>(fallbacks.keySet());
|
||||
|
||||
ServerInfo server;
|
||||
if ((server = getForcedHost(player.getPendingConnection())) == null
|
||||
&& (server = getDNS(player.getPendingConnection())) == null
|
||||
&& (server = getReconnectServer(player)) == null) {
|
||||
if (!fallbacks.isEmpty()) {
|
||||
server = new LinkedList<ServerInfo>(fallbacks.values()).getFirst();
|
||||
}
|
||||
} else {
|
||||
queue.addFirst(server.getName());
|
||||
}
|
||||
|
||||
|
||||
if (server != null && player instanceof UserConnection)
|
||||
((UserConnection) player).setServerJoinQueue(new LinkedList<>(fallbacks.keySet()));
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user