Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Fix up some stuff
Dieser Commit ist enthalten in:
Ursprung
904e1367a2
Commit
1515c5069b
@ -246,7 +246,8 @@ public class VelocityServer implements ProxyServer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-register servers. If we are replacing a server, we must evacuate players.
|
// Re-register servers. If a server is being replaced, make sure to note what players need to
|
||||||
|
// move back to a fallback server.
|
||||||
Collection<ConnectedPlayer> evacuate = new ArrayList<>();
|
Collection<ConnectedPlayer> evacuate = new ArrayList<>();
|
||||||
for (Map.Entry<String, String> entry : newConfiguration.getServers().entrySet()) {
|
for (Map.Entry<String, String> entry : newConfiguration.getServers().entrySet()) {
|
||||||
ServerInfo newInfo =
|
ServerInfo newInfo =
|
||||||
@ -267,29 +268,32 @@ public class VelocityServer implements ProxyServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CountDownLatch latch = new CountDownLatch(evacuate.size());
|
// If we had any players to evacuate, let's move them now. Wait until they are all moved off.
|
||||||
for (ConnectedPlayer player : evacuate) {
|
if (!evacuate.isEmpty()) {
|
||||||
Optional<RegisteredServer> next = player.getNextServerToTry();
|
CountDownLatch latch = new CountDownLatch(evacuate.size());
|
||||||
if (next.isPresent()) {
|
for (ConnectedPlayer player : evacuate) {
|
||||||
player.createConnectionRequest(next.get()).connectWithIndication()
|
Optional<RegisteredServer> next = player.getNextServerToTry();
|
||||||
.whenComplete((success, ex) -> {
|
if (next.isPresent()) {
|
||||||
if (ex != null || success == null || !success) {
|
player.createConnectionRequest(next.get()).connectWithIndication()
|
||||||
player.disconnect(TextComponent.of("Your server has been changed, but we could "
|
.whenComplete((success, ex) -> {
|
||||||
+ "not move you to any fallback servers."));
|
if (ex != null || success == null || !success) {
|
||||||
}
|
player.disconnect(TextComponent.of("Your server has been changed, but we could "
|
||||||
latch.countDown();
|
+ "not move you to any fallback servers."));
|
||||||
});
|
}
|
||||||
} else {
|
latch.countDown();
|
||||||
latch.countDown();
|
});
|
||||||
player.disconnect(TextComponent.of("Your server has been changed, but we could "
|
} else {
|
||||||
+ "not move you to any fallback servers."));
|
latch.countDown();
|
||||||
|
player.disconnect(TextComponent.of("Your server has been changed, but we could "
|
||||||
|
+ "not move you to any fallback servers."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
latch.await();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.error("Interrupted whilst moving players", e);
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
try {
|
|
||||||
latch.await();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
logger.error("Interrupted whilst moving players", e);
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a new bind address, bind to it
|
// If we have a new bind address, bind to it
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren