Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-25 15:50:19 +01:00
Move TriState converter
Dieser Commit ist enthalten in:
Ursprung
e798f0d906
Commit
5c424c1da7
@ -39,17 +39,6 @@ public interface PermissionSubject {
|
||||
* @return subject's permission checker
|
||||
*/
|
||||
default PermissionChecker getPermissionChecker() {
|
||||
return permission -> {
|
||||
final Tristate state = getPermissionValue(permission);
|
||||
if (state == Tristate.TRUE) {
|
||||
return TriState.TRUE;
|
||||
} else if (state == Tristate.UNDEFINED) {
|
||||
return TriState.NOT_SET;
|
||||
} else if (state == Tristate.FALSE) {
|
||||
return TriState.FALSE;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
};
|
||||
return permission -> getPermissionValue(permission).toAdventureTriState();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
package com.velocitypowered.api.permission;
|
||||
|
||||
import net.kyori.adventure.util.TriState;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
@ -81,4 +82,16 @@ public enum Tristate {
|
||||
public boolean asBoolean() {
|
||||
return this.booleanValue;
|
||||
}
|
||||
|
||||
public TriState toAdventureTriState() {
|
||||
if (this == Tristate.TRUE) {
|
||||
return TriState.TRUE;
|
||||
} else if (this == Tristate.UNDEFINED) {
|
||||
return TriState.NOT_SET;
|
||||
} else if (this == Tristate.FALSE) {
|
||||
return TriState.FALSE;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren