3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-26 08:10:14 +01:00

Move TriState converter

Dieser Commit ist enthalten in:
lexikiq 2021-06-12 20:01:42 -04:00
Ursprung e798f0d906
Commit 5c424c1da7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: AE6C11E94FDBB116
2 geänderte Dateien mit 14 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -39,17 +39,6 @@ public interface PermissionSubject {
* @return subject's permission checker * @return subject's permission checker
*/ */
default PermissionChecker getPermissionChecker() { default PermissionChecker getPermissionChecker() {
return permission -> { return permission -> getPermissionValue(permission).toAdventureTriState();
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();
}
};
} }
} }

Datei anzeigen

@ -7,6 +7,7 @@
package com.velocitypowered.api.permission; package com.velocitypowered.api.permission;
import net.kyori.adventure.util.TriState;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
/** /**
@ -81,4 +82,16 @@ public enum Tristate {
public boolean asBoolean() { public boolean asBoolean() {
return this.booleanValue; 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();
}
}
} }