Future wouldn't have been completed

This commit is contained in:
Flori4nK 2021-04-20 22:16:30 +02:00
parent f8e968fb9e
commit b26392c980
No known key found for this signature in database
GPG Key ID: A45F90DA3BF1D357

View File

@ -19,6 +19,8 @@ import net.luckperms.api.LuckPermsProvider;
import org.slf4j.Logger;
import java.nio.file.Path;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletionException;
@Plugin(id = "@ID@", name = "@NAME@", version = "@VERSION@", description = "@DESCRIPTION@", authors = {"ActualPlayer"}, dependencies = { @Dependency(id = "luckperms", optional = true) })
public class RememberMe {
@ -72,10 +74,13 @@ public class RememberMe {
handler.getLastServerName(chooseServerEvent.getPlayer().getUniqueId()).thenAcceptAsync(lastServerName -> {
if (lastServerName != null) {
getServer().getServer(lastServerName).ifPresent((registeredServer) -> {
registeredServer.ping().thenRun(() -> {
try {
registeredServer.ping().join();
} catch(CancellationException|CompletionException exception) {
return;
}
chooseServerEvent.setInitialServer(registeredServer);
});
});
}
}).join();
}