mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
Throw exception earlier if an invalid permission is added/removed via Vault (#526)
This commit is contained in:
parent
76bfde4d77
commit
f1a50f433f
@ -28,8 +28,9 @@ package me.lucko.luckperms.bukkit.vault;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.DataMutateResult;
|
|
||||||
import me.lucko.luckperms.api.Node;
|
import me.lucko.luckperms.api.Node;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
@ -419,36 +420,26 @@ public class VaultPermissionHook extends Permission {
|
|||||||
// utility methods for modifying the state of PermissionHolders
|
// utility methods for modifying the state of PermissionHolders
|
||||||
|
|
||||||
private void holderAddPermission(PermissionHolder holder, String permission, String world) {
|
private void holderAddPermission(PermissionHolder holder, String permission, String world) {
|
||||||
|
Preconditions.checkNotNull(permission, "permission is null");
|
||||||
|
Preconditions.checkArgument(!permission.isEmpty(), "permission is an empty string");
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
DataMutateResult result;
|
if (holder.setPermission(NodeFactory.make(permission, true, getServer(), world)).asBoolean()) {
|
||||||
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
|
|
||||||
result = holder.setPermission(NodeFactory.make(permission, true, getServer(), world));
|
|
||||||
} else {
|
|
||||||
result = holder.setPermission(NodeFactory.make(permission, true, getServer()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.asBoolean()) {
|
|
||||||
holderSave(holder);
|
holderSave(holder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void holderRemovePermission(PermissionHolder holder, String permission, String world) {
|
private void holderRemovePermission(PermissionHolder holder, String permission, String world) {
|
||||||
|
Preconditions.checkNotNull(permission, "permission is null");
|
||||||
|
Preconditions.checkArgument(!permission.isEmpty(), "permission is an empty string");
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
DataMutateResult result;
|
if (holder.unsetPermission(NodeFactory.make(permission, getServer(), world)).asBoolean()) {
|
||||||
if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) {
|
|
||||||
result = holder.unsetPermission(NodeFactory.make(permission, getServer(), world));
|
|
||||||
} else {
|
|
||||||
result = holder.unsetPermission(NodeFactory.make(permission, getServer()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.asBoolean()) {
|
|
||||||
holderSave(holder);
|
holderSave(holder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void holderSave(PermissionHolder holder) {
|
void holderSave(PermissionHolder holder) {
|
||||||
if (holder instanceof User) {
|
if (holder instanceof User) {
|
||||||
User u = (User) holder;
|
User u = (User) holder;
|
||||||
plugin.getStorage().saveUser(u).thenRunAsync(() -> u.getRefreshBuffer().request(), plugin.getScheduler().async());
|
plugin.getStorage().saveUser(u).thenRunAsync(() -> u.getRefreshBuffer().request(), plugin.getScheduler().async());
|
||||||
|
Loading…
Reference in New Issue
Block a user