Cleanup permission calculation
This commit is contained in:
@@ -44,10 +44,8 @@ public class AttachmentProcessor implements PermissionProcessor {
|
||||
return Tristate.UNDEFINED;
|
||||
}
|
||||
|
||||
if (m.containsKey(permission)) {
|
||||
return Tristate.fromBoolean(m.get(permission).getValue());
|
||||
}
|
||||
return Tristate.UNDEFINED;
|
||||
PermissionAttachmentInfo pai = m.get(permission);
|
||||
return pai == null ? Tristate.UNDEFINED : Tristate.fromBoolean(pai.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import me.lucko.luckperms.bukkit.inject.LPPermissible;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class AutoOPListener implements ContextListener<Player> {
|
||||
|
||||
@@ -39,7 +40,7 @@ public class AutoOPListener implements ContextListener<Player> {
|
||||
}
|
||||
|
||||
Map<String, Boolean> backing = permissible.getUser().getUserData().getPermissionData(permissible.calculateContexts()).getImmutableBacking();
|
||||
boolean op = backing.containsKey("luckperms.autoop") && backing.get("luckperms.autoop");
|
||||
boolean op = Optional.ofNullable(backing.get("luckperms.autoop")).orElse(false);
|
||||
subject.setOp(op);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,10 +41,6 @@ public class DefaultsProcessor implements PermissionProcessor {
|
||||
}
|
||||
|
||||
Permission defPerm = Bukkit.getServer().getPluginManager().getPermission(permission);
|
||||
if (defPerm != null) {
|
||||
return Tristate.fromBoolean(defPerm.getDefault().getValue(isOp));
|
||||
} else {
|
||||
return Tristate.UNDEFINED;
|
||||
}
|
||||
return defPerm == null ? Tristate.UNDEFINED : Tristate.fromBoolean(defPerm.getDefault().getValue(isOp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,11 +97,9 @@ public class DefaultsProvider {
|
||||
|
||||
public Tristate hasDefault(String permission, boolean isOp) {
|
||||
Map<String, Boolean> map = isOp ? op : nonOp;
|
||||
if (!map.containsKey(permission)) {
|
||||
return Tristate.UNDEFINED;
|
||||
}
|
||||
|
||||
return Tristate.fromBoolean(map.get(permission));
|
||||
Boolean b = map.get(permission);
|
||||
return b == null ? Tristate.UNDEFINED : Tristate.fromBoolean(b);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
|
||||
Reference in New Issue
Block a user