Prevent deadlock in LuckPermsHandler #1350

This commit is contained in:
Gabriele C 2017-10-09 09:02:14 +02:00
parent 7afda20288
commit 45dda0deba

View File

@ -19,6 +19,9 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
/**
@ -63,7 +66,11 @@ public class LuckPermsHandler implements PermissionHandler {
if (user == null) {
// user not loaded, we need to load them from the storage.
// this is a blocking call.
luckPermsApi.getStorage().loadUser(playerUuid).join();
try {
luckPermsApi.getStorage().loadUser(playerUuid).get(1, TimeUnit.SECONDS);
} catch (InterruptedException | TimeoutException | ExecutionException e) {
e.printStackTrace();
}
// then grab a new instance
user = luckPermsApi.getUser(playerUuid);