merged pull request #4 to fix #3 - add ping check to fix crash when last logged-out server is offline

This commit is contained in:
ActualPlayer 2021-05-15 10:37:23 +02:00
commit d83c9c9851
3 changed files with 14 additions and 3 deletions

View File

@ -1,5 +1,8 @@
# Remember Me
Remember Me is a plugin for the Velocity Minecraft Proxy that allows users to login to the server they last logged out on
Remember Me is a plugin for the Velocity Minecraft Proxy that allows users to login to the server they last logged out on.
At the moment of writing the latest version of RememberMe requires Velocity 1.1 to work. Velocity 1.1 is not fully released yet but can be downloaded from their jenkins.
RememberMe versions < 1.2 can be used with the currently released version of Velocity, but have a mandatory dependency on Luckperms and have no further support.
## Permissions

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 {
@ -71,7 +73,14 @@ public class RememberMe {
if (!chooseServerEvent.getPlayer().hasPermission("rememberme.notransfer")) {
handler.getLastServerName(chooseServerEvent.getPlayer().getUniqueId()).thenAcceptAsync(lastServerName -> {
if (lastServerName != null) {
getServer().getServer(lastServerName).ifPresent(chooseServerEvent::setInitialServer);
getServer().getServer(lastServerName).ifPresent((registeredServer) -> {
try {
registeredServer.ping().join();
} catch(CancellationException|CompletionException exception) {
return;
}
chooseServerEvent.setInitialServer(registeredServer);
});
}
}).join();
}

View File

@ -12,7 +12,6 @@ import net.luckperms.api.node.NodeType;
import net.luckperms.api.node.types.MetaNode;
import net.luckperms.api.query.QueryMode;
import net.luckperms.api.query.QueryOptions;
import org.checkerframework.checker.nullness.Opt;
import java.util.Collection;
import java.util.Optional;