From 6fdd349654c296ca8420391e8e7738bf3054b0e1 Mon Sep 17 00:00:00 2001 From: Luck Date: Fri, 29 Nov 2019 12:16:24 +0000 Subject: [PATCH] Fix (un)setting nodes through Vault with null worlds (#1826) --- .../bukkit/vault/LuckPermsVaultPermission.java | 11 +++++++++-- .../inject/permissible/LPPermissionAttachment.java | 3 +-- .../me/lucko/luckperms/sponge/model/SpongeGroup.java | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java index b1dd3dbf9..96f4ec851 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java @@ -51,7 +51,6 @@ import net.luckperms.api.context.MutableContextSet; import net.luckperms.api.model.data.DataType; import net.luckperms.api.query.Flag; import net.luckperms.api.query.QueryOptions; -import net.luckperms.api.util.Result; import net.luckperms.api.util.Tristate; import net.milkbowl.vault.permission.Permission; @@ -438,7 +437,11 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission { logMsg("#holderAddPermission: %s - %s - %s", holder.getPlainDisplayName(), permission, world); } - if (((Result) holder.setNode(DataType.NORMAL, NodeBuilders.determineMostApplicable(permission).value(true).withContext(DefaultContextKeys.SERVER_KEY, getVaultServer()).withContext(DefaultContextKeys.WORLD_KEY, world).build(), true)).wasSuccessful()) { + if (world == null) { + world = "global"; + } + + if (holder.setNode(DataType.NORMAL, NodeBuilders.determineMostApplicable(permission).value(true).withContext(DefaultContextKeys.SERVER_KEY, getVaultServer()).withContext(DefaultContextKeys.WORLD_KEY, world).build(), true).wasSuccessful()) { return holderSave(holder); } return false; @@ -452,6 +455,10 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission { logMsg("#holderRemovePermission: %s - %s - %s", holder.getPlainDisplayName(), permission, world); } + if (world == null) { + world = "global"; + } + if (holder.unsetNode(DataType.NORMAL, NodeBuilders.determineMostApplicable(permission).withContext(DefaultContextKeys.SERVER_KEY, getVaultServer()).withContext(DefaultContextKeys.WORLD_KEY, world).build()).wasSuccessful()) { return holderSave(holder); } diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LPPermissionAttachment.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LPPermissionAttachment.java index 396f0aa18..4551249e9 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LPPermissionAttachment.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LPPermissionAttachment.java @@ -35,7 +35,6 @@ import me.lucko.luckperms.nukkit.inject.dummy.DummyPlugin; import net.luckperms.api.model.data.DataType; import net.luckperms.api.node.Node; import net.luckperms.api.node.metadata.NodeMetadataKey; -import net.luckperms.api.util.Result; import cn.nukkit.permission.Permission; import cn.nukkit.permission.PermissionAttachment; @@ -192,7 +191,7 @@ public class LPPermissionAttachment extends PermissionAttachment { // set the transient node User user = this.permissible.getUser(); - ((Result) user.setNode(DataType.TRANSIENT, node, true)).wasSuccessful(); + user.setNode(DataType.TRANSIENT, node, true).wasSuccessful(); } private void unsetPermissionInternal(String name) { diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/model/SpongeGroup.java b/sponge/src/main/java/me/lucko/luckperms/sponge/model/SpongeGroup.java index 58fc4d0f7..5a40bcb7e 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/model/SpongeGroup.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/model/SpongeGroup.java @@ -40,7 +40,6 @@ public class SpongeGroup extends Group implements SpongePermissionHolder { @Override protected void invalidateCache() { super.invalidateCache(); - this.spongeData.fireUpdateEvent(); }