bugfix nullpointer in filehandler

This commit is contained in:
ActualPlayer 2021-05-17 18:04:18 +02:00
parent 48b3db534d
commit 891584611c
2 changed files with 7 additions and 7 deletions

View File

@ -6,7 +6,7 @@ plugins {
sourceCompatibility = JavaVersion.VERSION_11
group 'com.actualplayer'
version '1.2.2'
version '1.2.3'
description 'A way for the user to login to the server he last connected to.'
repositories {

View File

@ -30,13 +30,13 @@ public class FileHandler implements IRememberMeHandler {
File userFile = FileUtils.getOrCreate(rememberMe.getDataFolderPath().resolve("data"), uuid.toString() + ".yml");
UserServer userServer = YamlUtils.readFile(userFile, UserServer.class);
if(userServer == null) return null;
Optional<RegisteredServer> serverOpt = rememberMe.getServer().getServer(userServer.getServer());
CompletableFuture<String> future = new CompletableFuture<>();
if(userServer == null) {
future.complete(null);
} else {
Optional<RegisteredServer> serverOpt = rememberMe.getServer().getServer(userServer.getServer());
future.complete(serverOpt.map(registeredServer -> registeredServer.getServerInfo().getName()).orElse(null));
}
return future;
} catch (IOException ex) {
return null;