fixed luckperms loading3

This commit is contained in:
ActualPlayer 2019-08-13 23:35:35 +02:00
parent ecf5491165
commit e8f4855eec
2 changed files with 10 additions and 7 deletions

View File

@ -63,10 +63,12 @@ public class RememberMe {
if (!loginEvent.getPlayer().hasPermission("rememberme.notransfer")) { if (!loginEvent.getPlayer().hasPermission("rememberme.notransfer")) {
handler.getLastServerName(loginEvent.getPlayer().getUniqueId()).thenAcceptAsync(lastServerName -> { handler.getLastServerName(loginEvent.getPlayer().getUniqueId()).thenAcceptAsync(lastServerName -> {
if (lastServerName != null) { if (lastServerName != null) {
getServer().getServer(lastServerName).ifPresent(lastServer -> loginEvent.getPlayer().createConnectionRequest(lastServer).connectWithIndication()); getServer().getServer(lastServerName).ifPresent(lastServer -> {
} loginEvent.getPlayer().createConnectionRequest(lastServer).connectWithIndication();
}); });
} }
}).join();
}
} }
@Subscribe @Subscribe

View File

@ -6,6 +6,8 @@ import me.lucko.luckperms.api.LuckPermsApi;
import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Node;
import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.User;
import me.lucko.luckperms.api.caching.MetaData; import me.lucko.luckperms.api.caching.MetaData;
import me.lucko.luckperms.api.context.ContextManager;
import me.lucko.luckperms.api.context.ImmutableContextSet;
import me.lucko.luckperms.api.manager.UserManager; import me.lucko.luckperms.api.manager.UserManager;
import java.util.Optional; import java.util.Optional;
@ -26,13 +28,12 @@ public class LuckPermsHandler implements IRememberMeHandler {
CompletableFuture<User> userFuture = userManager.loadUser(uuid); CompletableFuture<User> userFuture = userManager.loadUser(uuid);
return userFuture.thenApply(user -> { return userFuture.thenApply(user -> {
if (user != null) { if (user != null) {
Optional<Contexts> contextsOpt = api.getContextManager().lookupApplicableContexts(user); ContextManager cm = api.getContextManager();
Contexts contexts = cm.lookupApplicableContexts(user).orElse(cm.getStaticContexts());
if (contextsOpt.isPresent()) { MetaData metaData = user.getCachedData().getMetaData(contexts);
MetaData metaData = user.getCachedData().getMetaData(contextsOpt.get());
return metaData.getMeta().getOrDefault("last-server", null); return metaData.getMeta().getOrDefault("last-server", null);
} }
}
return null; return null;
}); });