mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-09-08 21:30:55 +02:00
Correctly implement Bukkit/Nukkit isPermissionSet method, inline with the behaviour in PermissibleBase (#1403)
This commit is contained in:
@@ -29,6 +29,8 @@ import com.google.common.collect.ImmutableList;
|
||||
|
||||
import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||
import me.lucko.luckperms.bukkit.calculator.DefaultsProcessor;
|
||||
import me.lucko.luckperms.common.calculator.result.TristateResult;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.context.ContextsSupplier;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
@@ -136,8 +138,17 @@ public class LPPermissible extends PermissibleBase {
|
||||
throw new NullPointerException("permission");
|
||||
}
|
||||
|
||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK).result();
|
||||
return ts != Tristate.UNDEFINED || Permission.DEFAULT_PERMISSION.getValue(isOp());
|
||||
TristateResult result = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission, PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK);
|
||||
if (result.result() == Tristate.UNDEFINED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ignore matches made from looking up in the permission map (replicate bukkit behaviour)
|
||||
if (result.processorClass() == DefaultsProcessor.class && "permission map".equals(result.cause())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -146,16 +157,7 @@ public class LPPermissible extends PermissibleBase {
|
||||
throw new NullPointerException("permission");
|
||||
}
|
||||
|
||||
Tristate ts = this.user.getCachedData().getPermissionData(this.contextsSupplier.getContexts()).getPermissionValue(permission.getName(), PermissionCheckEvent.Origin.PLATFORM_LOOKUP_CHECK).result();
|
||||
if (ts != Tristate.UNDEFINED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) {
|
||||
return Permission.DEFAULT_PERMISSION.getValue(isOp());
|
||||
} else {
|
||||
return permission.getDefault().getValue(isOp());
|
||||
}
|
||||
return isPermissionSet(permission.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,10 +181,10 @@ public class LPPermissible extends PermissibleBase {
|
||||
return ts.asBoolean();
|
||||
}
|
||||
|
||||
if (!this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) {
|
||||
return Permission.DEFAULT_PERMISSION.getValue(isOp());
|
||||
} else {
|
||||
if (this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) {
|
||||
return permission.getDefault().getValue(isOp());
|
||||
} else {
|
||||
return Permission.DEFAULT_PERMISSION.getValue(isOp());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -177,8 +177,8 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
||||
// if the key is a player, check their LPPermissible first
|
||||
if (isPlayer) {
|
||||
Permissible p = (Permissible) key;
|
||||
if (p.isPermissionSet(this.permission)) {
|
||||
return p.hasPermission(this.permission);
|
||||
if (p.hasPermission(this.permission)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,8 +191,8 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
||||
// then try the permissible, if we haven't already
|
||||
if (!isPlayer && key instanceof Permissible) {
|
||||
Permissible p = (Permissible) key;
|
||||
if (p.isPermissionSet(this.permission)) {
|
||||
return p.hasPermission(this.permission);
|
||||
if (p.hasPermission(this.permission)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public final class LPSubscriptionMap extends HashMap<String, Map<Permissible, Bo
|
||||
public @NonNull Set<Permissible> keySet() {
|
||||
// gather players (LPPermissibles)
|
||||
Set<Permissible> players = LPSubscriptionMap.this.plugin.getBootstrap().getServer().getOnlinePlayers().stream()
|
||||
.filter(player -> player.isPermissionSet(this.permission))
|
||||
.filter(player -> player.hasPermission(this.permission) || player.isPermissionSet(this.permission))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// then combine the players with the backing map
|
||||
|
Reference in New Issue
Block a user