Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
expose PermissionChecker and use this
Dieser Commit ist enthalten in:
Ursprung
cc67b99c8b
Commit
48e4fa637e
@ -22,7 +22,7 @@ public interface PermissionSubject {
|
|||||||
* @return whether or not the subject has the permission
|
* @return whether or not the subject has the permission
|
||||||
*/
|
*/
|
||||||
default boolean hasPermission(String permission) {
|
default boolean hasPermission(String permission) {
|
||||||
return getPermissionValue(permission).toBooleanOrElse(false);
|
return this.getPermissionChecker().test(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,14 +31,14 @@ public interface PermissionSubject {
|
|||||||
* @param permission the permission
|
* @param permission the permission
|
||||||
* @return the value the permission is set to
|
* @return the value the permission is set to
|
||||||
*/
|
*/
|
||||||
TriState getPermissionValue(String permission);
|
default TriState getPermissionValue(String permission) {
|
||||||
|
return this.getPermissionChecker().value(permission);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the permission checker for the subject.
|
* Gets the permission checker for the subject.
|
||||||
*
|
*
|
||||||
* @return subject's permission checker
|
* @return subject's permission checker
|
||||||
*/
|
*/
|
||||||
default PermissionChecker getPermissionChecker() {
|
PermissionChecker getPermissionChecker();
|
||||||
return this::getPermissionValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -908,8 +908,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TriState getPermissionValue(String permission) {
|
public PermissionChecker getPermissionChecker() {
|
||||||
return permissionChecker.value(permission);
|
return this.permissionChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,8 +75,8 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull TriState getPermissionValue(@NonNull String permission) {
|
public PermissionChecker getPermissionChecker() {
|
||||||
return this.permissionChecker.value(permission);
|
return this.permissionChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package com.velocitypowered.proxy.command;
|
package com.velocitypowered.proxy.command;
|
||||||
|
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
|
import net.kyori.adventure.permission.PermissionChecker;
|
||||||
import net.kyori.adventure.util.TriState;
|
import net.kyori.adventure.util.TriState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +29,7 @@ public class MockCommandSource implements CommandSource {
|
|||||||
public static final CommandSource INSTANCE = new MockCommandSource();
|
public static final CommandSource INSTANCE = new MockCommandSource();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TriState getPermissionValue(final String permission) {
|
public PermissionChecker getPermissionChecker() {
|
||||||
return TriState.NOT_SET;
|
return PermissionChecker.always(TriState.NOT_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren