Use .setCancelServers() for fallbacks

This method (as far as I know) is exclusive to GalaxiBungee. The old method is still available as a fallback.
This commit is contained in:
ME1312 2019-05-23 13:03:14 -04:00
parent b808a62fcb
commit 8514ea5c26
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
4 changed files with 10 additions and 6 deletions

View File

@ -34,7 +34,7 @@ public class SmartReconnectHandler implements ReconnectHandler {
if (fallbacks.isEmpty()) {
return null;
} else {
if (player instanceof UserConnection) ((UserConnection) player).setServerJoinQueue(new LinkedBlockingQueue<>(fallbacks.keySet()));
if (player instanceof UserConnection) ((UserConnection) player).setServerJoinQueue(new LinkedList<>(fallbacks.keySet()));
return new LinkedList<Map.Entry<String, ServerInfo>>(fallbacks.entrySet()).getFirst().getValue();
}
}

View File

@ -856,11 +856,13 @@ public final class SubPlugin extends BungeeCord implements Listener {
ServerInfo next = new LinkedList<Map.Entry<String, ServerInfo>>(fallbacks.entrySet()).getFirst().getValue();
e.setCancelServer(next);
if (Util.isException(() -> Util.reflect(ServerKickEvent.class.getDeclaredMethod("setCancelServers", ServerInfo[].class), e, (Object) fallbacks.values().toArray(new ServerInfo[0])))) {
((UserConnection) e.getPlayer()).setServerJoinQueue(new LinkedBlockingQueue<>(fallbacks.keySet()));
((UserConnection) e.getPlayer()).connect(next, null, true);
}
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = Byte.MAX_VALUE)
public void fallbackFound(ServerConnectedEvent e) {

View File

@ -34,7 +34,7 @@ public class SmartReconnectHandler implements ReconnectHandler {
if (fallbacks.isEmpty()) {
return null;
} else {
if (player instanceof UserConnection) ((UserConnection) player).setServerJoinQueue(new LinkedBlockingQueue<>(fallbacks.keySet()));
if (player instanceof UserConnection) ((UserConnection) player).setServerJoinQueue(new LinkedList<>(fallbacks.keySet()));
return new LinkedList<Map.Entry<String, ServerInfo>>(fallbacks.entrySet()).getFirst().getValue();
}
}

View File

@ -354,11 +354,13 @@ public final class SubPlugin extends BungeeCord implements Listener {
ServerInfo next = new LinkedList<Map.Entry<String, ServerInfo>>(fallbacks.entrySet()).getFirst().getValue();
e.setCancelServer(next);
((UserConnection) e.getPlayer()).setServerJoinQueue(new LinkedBlockingQueue<>(fallbacks.keySet()));
if (Util.isException(() -> Util.reflect(ServerKickEvent.class.getDeclaredMethod("setCancelServers", ServerInfo[].class), e, (Object) fallbacks.values().toArray(new ServerInfo[0])))) {
((UserConnection) e.getPlayer()).setServerJoinQueue(new LinkedList<>(fallbacks.keySet()));
((UserConnection) e.getPlayer()).connect(next, null, true);
}
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = Byte.MAX_VALUE)
public void fallbackFound(ServerConnectedEvent e) {