Fix NPE in Vault contextForLookup method

Fixes CodeCrafter47/BungeeTabListPlus#415
This commit is contained in:
Luck 2019-04-03 10:01:18 +01:00
parent 8eed4558f4
commit 7cd8e8bf5b
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -49,9 +49,11 @@ import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
/**
@ -362,10 +364,10 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
}
// utility method for getting a contexts instance for a given vault lookup.
Contexts contextForLookup(UUID uuid, String world) {
Contexts contextForLookup(@Nullable UUID uuid, @Nullable String world) {
MutableContextSet context;
Player player = this.plugin.getBootstrap().getPlayer(uuid).orElse(null);
Player player = Optional.ofNullable(uuid).flatMap(u -> this.plugin.getBootstrap().getPlayer(u)).orElse(null);
if (player != null) {
context = this.plugin.getContextManager().getApplicableContext(player).mutableCopy();
} else {
@ -397,7 +399,7 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
boolean op = false;
if (player != null) {
op = player.isOp();
} else if (uuid.version() == 2) { // npc
} else if (uuid != null && uuid.version() == 2) { // npc
op = this.plugin.getConfiguration().get(ConfigKeys.VAULT_NPC_OP_STATUS);
}