mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-03 17:39:31 +01:00
Fix NPE when trying to set (chat)meta with a null would through Vault (#1920)
This commit is contained in:
parent
c1e3660551
commit
098f8d8231
@ -42,6 +42,7 @@ import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeBuilder;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
import net.luckperms.api.query.Flag;
|
||||
@ -237,12 +238,12 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
metaAccumulator.complete();
|
||||
int priority = metaAccumulator.getChatMeta(type).keySet().stream().mapToInt(e -> e).max().orElse(0) + 10;
|
||||
|
||||
NodeBuilder<?, ?> chatMetaNode = type == ChatMetaType.PREFIX ? Prefix.builder(value, priority) : Suffix.builder(value, priority);
|
||||
chatMetaNode.withContext(DefaultContextKeys.SERVER_KEY, this.vaultPermission.getVaultServer());
|
||||
chatMetaNode.withContext(DefaultContextKeys.WORLD_KEY, world);
|
||||
Node node = type.builder(value, priority)
|
||||
.withContext(DefaultContextKeys.SERVER_KEY, this.vaultPermission.getVaultServer())
|
||||
.withContext(DefaultContextKeys.WORLD_KEY, world == null ? "global" : world).build();
|
||||
|
||||
// assume success
|
||||
holder.setNode(DataType.NORMAL, chatMetaNode.build(), true);
|
||||
holder.setNode(DataType.NORMAL, node, true);
|
||||
this.vaultPermission.holderSave(holder);
|
||||
}
|
||||
|
||||
@ -264,7 +265,7 @@ public class LuckPermsVaultChat extends AbstractVaultChat {
|
||||
}
|
||||
|
||||
metaNode.withContext(DefaultContextKeys.SERVER_KEY, this.vaultPermission.getVaultServer());
|
||||
metaNode.withContext(DefaultContextKeys.WORLD_KEY, world);
|
||||
metaNode.withContext(DefaultContextKeys.WORLD_KEY, world == null ? "global" : world);
|
||||
|
||||
// assume success
|
||||
holder.setNode(DataType.NORMAL, metaNode.build(), true);
|
||||
|
@ -48,6 +48,7 @@ import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.query.Flag;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
import net.luckperms.api.util.Tristate;
|
||||
@ -398,11 +399,12 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
||||
Objects.requireNonNull(permission, "permission is null");
|
||||
Preconditions.checkArgument(!permission.isEmpty(), "permission is an empty string");
|
||||
|
||||
if (world == null) {
|
||||
world = "global";
|
||||
}
|
||||
Node node = NodeBuilders.determineMostApplicable(permission)
|
||||
.withContext(DefaultContextKeys.SERVER_KEY, getVaultServer())
|
||||
.withContext(DefaultContextKeys.WORLD_KEY, world == null ? "global" : world)
|
||||
.build();
|
||||
|
||||
if (holder.setNode(DataType.NORMAL, NodeBuilders.determineMostApplicable(permission).value(true).withContext(DefaultContextKeys.SERVER_KEY, getVaultServer()).withContext(DefaultContextKeys.WORLD_KEY, world).build(), true).wasSuccessful()) {
|
||||
if (holder.setNode(DataType.NORMAL, node, true).wasSuccessful()) {
|
||||
return holderSave(holder);
|
||||
}
|
||||
return false;
|
||||
@ -412,11 +414,12 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
||||
Objects.requireNonNull(permission, "permission is null");
|
||||
Preconditions.checkArgument(!permission.isEmpty(), "permission is an empty string");
|
||||
|
||||
if (world == null) {
|
||||
world = "global";
|
||||
}
|
||||
Node node = NodeBuilders.determineMostApplicable(permission)
|
||||
.withContext(DefaultContextKeys.SERVER_KEY, getVaultServer())
|
||||
.withContext(DefaultContextKeys.WORLD_KEY, world == null ? "global" : world)
|
||||
.build();
|
||||
|
||||
if (holder.unsetNode(DataType.NORMAL, NodeBuilders.determineMostApplicable(permission).withContext(DefaultContextKeys.SERVER_KEY, getVaultServer()).withContext(DefaultContextKeys.WORLD_KEY, world).build()).wasSuccessful()) {
|
||||
if (holder.unsetNode(DataType.NORMAL, node).wasSuccessful()) {
|
||||
return holderSave(holder);
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user