3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Merge branch 'RealBauHD-use/adventure-permission' into dev/5.0.0

Dieser Commit ist enthalten in:
Andrew Steinborn 2023-10-27 17:10:35 -04:00
Commit 9a8fffaddf
13 geänderte Dateien mit 77 neuen und 222 gelöschten Zeilen

Datei anzeigen

@ -9,9 +9,9 @@ package com.velocitypowered.api.event.permission;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.annotation.AwaitingEvent;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.permission.PermissionProvider;
import com.velocitypowered.api.permission.PermissionSubject;
import net.kyori.adventure.permission.PermissionChecker;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@ -44,13 +44,13 @@ public final class PermissionsSetupEvent {
}
/**
* Uses the provider function to obtain a {@link PermissionFunction} for the subject.
* Uses the provider function to obtain a {@link PermissionChecker} for the subject.
*
* @param subject the subject
* @return the obtained permission function
*/
public PermissionFunction createFunction(PermissionSubject subject) {
return this.provider.createFunction(subject);
public PermissionChecker createChecker(PermissionSubject subject) {
return this.provider.createChecker(subject);
}
public PermissionProvider getProvider() {
@ -58,7 +58,7 @@ public final class PermissionsSetupEvent {
}
/**
* Sets the {@link PermissionFunction} that should be used for the subject.
* Sets the {@link PermissionChecker} that should be used for the subject.
*
* <p>Specifying <code>null</code> will reset the provider to the default
* instance given when the event was posted.</p>

Datei anzeigen

@ -1,38 +0,0 @@
/*
* Copyright (C) 2018-2021 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.permission;
/**
* Function that calculates the permission settings for a given {@link PermissionSubject}.
*/
@FunctionalInterface
public interface PermissionFunction {
/**
* A permission function that always returns {@link Tristate#TRUE}.
*/
PermissionFunction ALWAYS_TRUE = p -> Tristate.TRUE;
/**
* A permission function that always returns {@link Tristate#FALSE}.
*/
PermissionFunction ALWAYS_FALSE = p -> Tristate.FALSE;
/**
* A permission function that always returns {@link Tristate#UNDEFINED}.
*/
PermissionFunction ALWAYS_UNDEFINED = p -> Tristate.UNDEFINED;
/**
* Gets the subjects setting for a particular permission.
*
* @param permission the permission
* @return the value the permission is set to
*/
Tristate getPermissionValue(String permission);
}

Datei anzeigen

@ -7,17 +7,19 @@
package com.velocitypowered.api.permission;
import net.kyori.adventure.permission.PermissionChecker;
/**
* Provides {@link PermissionFunction}s for {@link PermissionSubject}s.
* Provides {@link PermissionChecker}s for {@link PermissionSubject}s.
*/
@FunctionalInterface
public interface PermissionProvider {
/**
* Creates a {@link PermissionFunction} for the subject.
* Creates a {@link PermissionChecker} for the subject.
*
* @param subject the subject
* @return the function
*/
PermissionFunction createFunction(PermissionSubject subject);
PermissionChecker createChecker(PermissionSubject subject);
}

Datei anzeigen

@ -8,6 +8,7 @@
package com.velocitypowered.api.permission;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.util.TriState;
/**
* Represents a object that has a set of queryable permissions.
@ -21,7 +22,7 @@ public interface PermissionSubject {
* @return whether or not the subject has the permission
*/
default boolean hasPermission(String permission) {
return getPermissionValue(permission).asBoolean();
return this.getPermissionChecker().test(permission);
}
/**
@ -30,14 +31,14 @@ public interface PermissionSubject {
* @param permission the permission
* @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.
*
* @return subject's permission checker
*/
default PermissionChecker getPermissionChecker() {
return permission -> getPermissionValue(permission).toAdventureTriState();
}
PermissionChecker getPermissionChecker();
}

Datei anzeigen

@ -1,118 +0,0 @@
/*
* Copyright (C) 2018-2023 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.permission;
import java.util.Optional;
import net.kyori.adventure.util.TriState;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Represents three different states of a setting.
*
* <p>Possible values:</p>
* <p></p>
* <ul>
* <li>{@link #TRUE} - a positive setting</li>
* <li>{@link #FALSE} - a negative (negated) setting</li>
* <li>{@link #UNDEFINED} - a non-existent setting</li>
* </ul>
*/
public enum Tristate {
/**
* A value indicating a positive setting.
*/
TRUE(true),
/**
* A value indicating a negative (negated) setting.
*/
FALSE(false),
/**
* A value indicating a non-existent setting.
*/
UNDEFINED(false);
/**
* Returns a {@link Tristate} from a boolean.
*
* @param val the boolean value
* @return {@link #TRUE} or {@link #FALSE}, if the value is <code>true</code> or
* <code>false</code>, respectively.
*/
public static Tristate fromBoolean(boolean val) {
return val ? TRUE : FALSE;
}
/**
* Returns a {@link Tristate} from a nullable boolean.
*
* <p>Unlike {@link #fromBoolean(boolean)}, this method returns {@link #UNDEFINED}
* if the value is null.</p>
*
* @param val the boolean value
* @return {@link #UNDEFINED}, {@link #TRUE} or {@link #FALSE}, if the value is <code>null</code>,
* <code>true</code> or <code>false</code>, respectively.
*/
public static Tristate fromNullableBoolean(@Nullable Boolean val) {
if (val == null) {
return UNDEFINED;
}
return val ? TRUE : FALSE;
}
/**
* Returns a {@link Tristate} from an {@link Optional}.
*
* <p>Unlike {@link #fromBoolean(boolean)}, this method returns {@link #UNDEFINED}
* if the value is empty.</p>
*
* @param val the optional boolean value
* @return {@link #UNDEFINED}, {@link #TRUE} or {@link #FALSE}, if the value is empty,
* <code>true</code> or <code>false</code>, respectively.
*/
public static Tristate fromOptionalBoolean(Optional<Boolean> val) {
return val.map(Tristate::fromBoolean).orElse(UNDEFINED);
}
private final boolean booleanValue;
Tristate(boolean booleanValue) {
this.booleanValue = booleanValue;
}
/**
* Returns the value of the Tristate as a boolean.
*
* <p>A value of {@link #UNDEFINED} converts to false.</p>
*
* @return a boolean representation of the Tristate.
*/
public boolean asBoolean() {
return this.booleanValue;
}
/**
* Returns the equivalent Adventure {@link TriState}.
*
* @return equivalent Adventure TriState
*/
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();
}
}
}

Datei anzeigen

@ -28,7 +28,6 @@ import com.mojang.brigadier.tree.ArgumentCommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.permission.Tristate;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
@ -39,6 +38,7 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.util.TriState;
/**
* Implements the Velocity default {@code /glist} command.
@ -60,7 +60,7 @@ public class GlistCommand {
LiteralCommandNode<CommandSource> totalNode = LiteralArgumentBuilder
.<CommandSource>literal("glist")
.requires(source ->
source.getPermissionValue("velocity.command.glist") == Tristate.TRUE)
source.getPermissionValue("velocity.command.glist") == TriState.TRUE)
.executes(this::totalCount)
.build();
ArgumentCommandNode<CommandSource, String> serverNode = RequiredArgumentBuilder

Datei anzeigen

@ -22,7 +22,6 @@ import static net.kyori.adventure.text.event.HoverEvent.showText;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.permission.Tristate;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.ServerConnection;
@ -37,6 +36,7 @@ import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.util.TriState;
/**
* Implements Velocity's {@code /server} command.
@ -161,6 +161,6 @@ public class ServerCommand implements SimpleCommand {
@Override
public boolean hasPermission(final SimpleCommand.Invocation invocation) {
return invocation.source().getPermissionValue("velocity.command.server") != Tristate.FALSE;
return invocation.source().getPermissionValue("velocity.command.server") != TriState.FALSE;
}
}

Datei anzeigen

@ -24,7 +24,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.permission.Tristate;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.plugin.PluginDescription;
import com.velocitypowered.api.proxy.ProxyServer;
@ -59,6 +58,7 @@ import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.util.TriState;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -200,7 +200,7 @@ public class VelocityCommand implements SimpleCommand {
@Override
public boolean hasPermission(final CommandSource source, final String @NonNull [] args) {
return source.getPermissionValue("velocity.command.reload") == Tristate.TRUE;
return source.getPermissionValue("velocity.command.reload") == TriState.TRUE;
}
}
@ -255,7 +255,7 @@ public class VelocityCommand implements SimpleCommand {
@Override
public boolean hasPermission(final CommandSource source, final String @NonNull [] args) {
return source.getPermissionValue("velocity.command.info") != Tristate.FALSE;
return source.getPermissionValue("velocity.command.info") != TriState.FALSE;
}
}
@ -336,7 +336,7 @@ public class VelocityCommand implements SimpleCommand {
@Override
public boolean hasPermission(final CommandSource source, final String @NonNull [] args) {
return source.getPermissionValue("velocity.command.plugins") == Tristate.TRUE;
return source.getPermissionValue("velocity.command.plugins") == TriState.TRUE;
}
}
@ -405,7 +405,7 @@ public class VelocityCommand implements SimpleCommand {
@Override
public boolean hasPermission(final CommandSource source, final String @NonNull [] args) {
return source.getPermissionValue("velocity.command.plugins") == Tristate.TRUE;
return source.getPermissionValue("velocity.command.plugins") == TriState.TRUE;
}
}
@ -481,7 +481,7 @@ public class VelocityCommand implements SimpleCommand {
@Override
public boolean hasPermission(CommandSource source, String @NonNull [] args) {
return source.getPermissionValue("velocity.command.heap") == Tristate.TRUE;
return source.getPermissionValue("velocity.command.heap") == TriState.TRUE;
}
}

Datei anzeigen

@ -27,7 +27,6 @@ import com.velocitypowered.api.event.permission.PermissionsSetupEvent;
import com.velocitypowered.api.event.player.GameProfileRequestEvent;
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.proxy.crypto.IdentifiedKey;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.util.GameProfile;
@ -47,6 +46,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.apache.logging.log4j.LogManager;
@ -111,14 +111,16 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
.thenAcceptAsync(event -> {
if (!mcConnection.isClosed()) {
// wait for permissions to load, then set the players permission function
final PermissionFunction function = event.createFunction(player);
if (function == null) {
logger.error("A plugin permission provider {} provided an invalid permission "
+ "function for player {}. This is a bug in the plugin, not in "
+ "Velocity. Falling back to the default permission function.",
event.getProvider().getClass().getName(), player.getUsername());
final PermissionChecker checker = event.createChecker(player);
if (checker == null) {
logger.error(
"A plugin permission provider {} provided an invalid permission function"
+ " for player {}. This is a bug in the plugin, not in Velocity. Falling"
+ " back to the default permission function.",
event.getProvider().getClass().getName(),
player.getUsername());
} else {
player.setPermissionFunction(function);
player.setPermissionChecker(checker);
}
startLoginCompletion(player);
}

Datei anzeigen

@ -35,9 +35,7 @@ import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
import com.velocitypowered.api.event.player.PlayerSettingsChangedEvent;
import com.velocitypowered.api.event.player.ServerPreConnectEvent;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.permission.PermissionProvider;
import com.velocitypowered.api.permission.Tristate;
import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection;
@ -79,7 +77,6 @@ import com.velocitypowered.proxy.tablist.VelocityTabList;
import com.velocitypowered.proxy.tablist.VelocityTabListLegacy;
import com.velocitypowered.proxy.util.ClosestLocaleMatcher;
import com.velocitypowered.proxy.util.DurationUtils;
import com.velocitypowered.proxy.util.TranslatableMapper;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import java.net.InetSocketAddress;
@ -102,6 +99,9 @@ import net.kyori.adventure.platform.facet.FacetPointers;
import net.kyori.adventure.platform.facet.FacetPointers.Type;
import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.KeybindComponent;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.flattener.ComponentFlattener;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
@ -109,6 +109,7 @@ import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import net.kyori.adventure.title.Title.Times;
import net.kyori.adventure.title.TitlePart;
import net.kyori.adventure.translation.GlobalTranslator;
import net.kyori.adventure.util.TriState;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@ -122,10 +123,15 @@ import org.jetbrains.annotations.NotNull;
public class ConnectedPlayer implements MinecraftConnectionAssociation, Player, KeyIdentifiable,
VelocityInboundConnection {
private static final int MAX_PLUGIN_CHANNELS = 1024;
private static final PlainTextComponentSerializer PASS_THRU_TRANSLATE =
PlainTextComponentSerializer.builder().flattener(TranslatableMapper.FLATTENER).build();
static final PermissionProvider DEFAULT_PERMISSIONS = s -> PermissionFunction.ALWAYS_UNDEFINED;
PlainTextComponentSerializer.builder()
.flattener(ComponentFlattener.basic().toBuilder()
.mapper(KeybindComponent.class, c -> "")
.mapper(TranslatableComponent.class, TranslatableComponent::key)
.build())
.build();
static final PermissionProvider DEFAULT_PERMISSIONS =
s -> PermissionChecker.always(TriState.NOT_SET);
private static final Logger logger = LogManager.getLogger(ConnectedPlayer.class);
@ -136,7 +142,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
private final MinecraftConnection connection;
private final @Nullable InetSocketAddress virtualHost;
private GameProfile profile;
private PermissionFunction permissionFunction;
private PermissionChecker permissionChecker;
private int tryIndex = 0;
private long ping = -1;
private final boolean onlineMode;
@ -155,13 +161,14 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
private final Queue<ResourcePackInfo> outstandingResourcePacks = new ArrayDeque<>();
private @Nullable ResourcePackInfo pendingResourcePack;
private @Nullable ResourcePackInfo appliedResourcePack;
private final @NotNull Pointers pointers =
Player.super.pointers().toBuilder().withDynamic(Identity.UUID, this::getUniqueId)
private final @NotNull Pointers pointers = Player.super.pointers().toBuilder()
.withDynamic(Identity.UUID, this::getUniqueId)
.withDynamic(Identity.NAME, this::getUsername)
.withDynamic(Identity.DISPLAY_NAME, () -> Component.text(this.getUsername()))
.withDynamic(Identity.LOCALE, this::getEffectiveLocale)
.withStatic(PermissionChecker.POINTER, getPermissionChecker())
.withStatic(FacetPointers.TYPE, Type.PLAYER).build();
.withDynamic(PermissionChecker.POINTER, () -> this.permissionChecker)
.withStatic(FacetPointers.TYPE, Type.PLAYER)
.build();
private @Nullable String clientBrand;
private @Nullable Locale effectiveLocale;
private @Nullable IdentifiedKey playerKey;
@ -176,7 +183,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
this.profile = profile;
this.connection = connection;
this.virtualHost = virtualHost;
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
this.permissionChecker = PermissionChecker.always(TriState.NOT_SET);
this.connectionPhase = connection.getType().getInitialClientPhase();
this.onlineMode = onlineMode;
@ -318,8 +325,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
return Optional.ofNullable(virtualHost);
}
void setPermissionFunction(PermissionFunction permissionFunction) {
this.permissionFunction = permissionFunction;
void setPermissionChecker(PermissionChecker permissionChecker) {
this.permissionChecker = permissionChecker;
}
@Override
@ -913,8 +920,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
}
@Override
public Tristate getPermissionValue(String permission) {
return permissionFunction.getPermissionValue(permission);
public PermissionChecker getPermissionChecker() {
return this.permissionChecker;
}
@Override

Datei anzeigen

@ -17,11 +17,7 @@
package com.velocitypowered.proxy.console;
import static com.velocitypowered.api.permission.PermissionFunction.ALWAYS_TRUE;
import com.velocitypowered.api.event.permission.PermissionsSetupEvent;
import com.velocitypowered.api.permission.PermissionFunction;
import com.velocitypowered.api.permission.Tristate;
import com.velocitypowered.api.proxy.ConsoleCommandSource;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.util.ClosestLocaleMatcher;
@ -36,6 +32,7 @@ import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import net.kyori.adventure.util.TriState;
import net.minecrell.terminalconsole.SimpleTerminalConsole;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
@ -58,7 +55,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
.logger(VelocityConsole.class);
private final VelocityServer server;
private PermissionFunction permissionFunction = ALWAYS_TRUE;
private PermissionChecker permissionChecker = PermissionChecker.always(TriState.TRUE);
private final @NotNull Pointers pointers = ConsoleCommandSource.super.pointers().toBuilder()
.withDynamic(PermissionChecker.POINTER, this::getPermissionChecker)
.withDynamic(Identity.LOCALE, () -> ClosestLocaleMatcher.INSTANCE
@ -77,8 +74,8 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
}
@Override
public @NonNull Tristate getPermissionValue(@NonNull String permission) {
return this.permissionFunction.getPermissionValue(permission);
public PermissionChecker getPermissionChecker() {
return this.permissionChecker;
}
/**
@ -93,16 +90,17 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
* Sets up permissions for the console.
*/
public void setupPermissions() {
PermissionsSetupEvent event = new PermissionsSetupEvent(this, s -> ALWAYS_TRUE);
PermissionsSetupEvent event = new PermissionsSetupEvent(
this, s -> PermissionChecker.always(TriState.TRUE));
// we can safely block here, this is before any listeners fire
this.permissionFunction = this.server.getEventManager().fire(event).join().createFunction(this);
if (this.permissionFunction == null) {
this.permissionChecker = this.server.getEventManager().fire(event).join().createChecker(this);
if (this.permissionChecker == null) {
logger.error(
"A plugin permission provider {} provided an invalid permission function"
+ " for the console. This is a bug in the plugin, not in Velocity. Falling"
+ " back to the default permission function.",
event.getProvider().getClass().getName());
this.permissionFunction = ALWAYS_TRUE;
this.permissionChecker = PermissionChecker.always(TriState.TRUE);
}
}

Datei anzeigen

@ -25,12 +25,12 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.permission.Tristate;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.proxy.event.MockEventManager;
import com.velocitypowered.proxy.event.VelocityEventManager;
import java.util.Arrays;
import java.util.Collection;
import net.kyori.adventure.util.TriState;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@ -66,7 +66,7 @@ abstract class CommandTestSuite {
final void assertPlayerSuggestions(final String input, final String... expectedSuggestions) {
final var player = mock(Player.class);
when(player.getPermissionValue(any())).thenReturn(Tristate.UNDEFINED);
when(player.getPermissionValue(any())).thenReturn(TriState.NOT_SET);
final var actual = manager.offerSuggestions(player, input).join();
assertEquals(Arrays.asList(expectedSuggestions), actual);
}

Datei anzeigen

@ -18,7 +18,8 @@
package com.velocitypowered.proxy.command;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.permission.Tristate;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.util.TriState;
/**
* A fake {@link CommandSource}.
@ -28,7 +29,7 @@ public class MockCommandSource implements CommandSource {
public static final CommandSource INSTANCE = new MockCommandSource();
@Override
public Tristate getPermissionValue(final String permission) {
return Tristate.UNDEFINED;
public PermissionChecker getPermissionChecker() {
return PermissionChecker.always(TriState.NOT_SET);
}
}