Mark Command.Builder#permission(String, TriState) as experimental.

Improve javadoc and HelpCommand.
This commit is contained in:
Konicai 2024-06-17 20:12:51 -05:00
parent 20d91cc201
commit 667486b95f
4 changed files with 13 additions and 5 deletions

View file

@ -167,14 +167,16 @@ public interface Command {
/** /**
* Sets the permission node and its default value. The usage of the default value is platform dependant * Sets the permission node and its default value. The usage of the default value is platform dependant
* and may or may not be used. For example, it may be registered to an underlying server. * and may or may not be used. For example, it may be registered to an underlying server.
<p> * <p>
* Extensions may instead listen for {@link GeyserRegisterPermissionsEvent} to register permissions, which * Extensions may instead listen for {@link GeyserRegisterPermissionsEvent} to register permissions,
* should be used if the same permission is required by multiple commands. * especially if the same permission is required by multiple commands. Also see this event for TriState meanings.
* *
* @param permission the permission node * @param permission the permission node
* @param defaultValue the node's default value * @param defaultValue the node's default value
* @return this builder * @return this builder
* @deprecated this method is experimental and may be removed in the future
*/ */
@Deprecated
Builder<T> permission(@NonNull String permission, @NonNull TriState defaultValue); Builder<T> permission(@NonNull String permission, @NonNull TriState defaultValue);
/** /**

View file

@ -39,7 +39,10 @@ import org.geysermc.geyser.api.util.TriState;
public interface GeyserRegisterPermissionsEvent extends Event { public interface GeyserRegisterPermissionsEvent extends Event {
/** /**
* Registers a permission node and its default value with the firer. * Registers a permission node and its default value with the firer.<p>
* {@link TriState#TRUE} corresponds to all players having the permission by default.<br>
* {@link TriState#NOT_SET} corresponds to only server operators having the permission by default (if such a concept exists on the platform).<br>
* {@link TriState#FALSE} corresponds to no players having the permission by default.<br>
* *
* @param permission the permission node to register * @param permission the permission node to register
* @param defaultValue the default value of the node * @param defaultValue the default value of the node

View file

@ -27,6 +27,7 @@ package org.geysermc.geyser.command;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionsEvent;
import org.geysermc.geyser.api.util.TriState; import org.geysermc.geyser.api.util.TriState;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.incendo.cloud.Command; import org.incendo.cloud.Command;
@ -62,6 +63,7 @@ public abstract class GeyserCommand implements org.geysermc.geyser.api.command.C
/** /**
* The default value of the permission node. * The default value of the permission node.
* A null value indicates that the permission node should not be registered whatsoever. * A null value indicates that the permission node should not be registered whatsoever.
* See {@link GeyserRegisterPermissionsEvent#register(String, TriState)} for TriState meanings.
*/ */
@Nullable @Nullable
private final TriState permissionDefault; private final TriState permissionDefault;

View file

@ -25,6 +25,7 @@
package org.geysermc.geyser.command.defaults; package org.geysermc.geyser.command.defaults;
import com.google.common.base.Predicates;
import org.geysermc.geyser.api.command.Command; import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.util.TriState; import org.geysermc.geyser.api.util.TriState;
import org.geysermc.geyser.command.GeyserCommand; import org.geysermc.geyser.command.GeyserCommand;
@ -71,7 +72,7 @@ public class HelpCommand extends GeyserCommand {
this.commands.stream() this.commands.stream()
.distinct() // remove aliases .distinct() // remove aliases
.filter(cmd -> !cmd.isBedrockOnly() || bedrockPlayer) // remove bedrock only commands if not a bedrock player .filter(bedrockPlayer ? Predicates.alwaysTrue() : cmd -> !cmd.isBedrockOnly()) // remove bedrock only commands if not a bedrock player
.filter(cmd -> source.hasPermission(cmd.permission())) .filter(cmd -> source.hasPermission(cmd.permission()))
.sorted(Comparator.comparing(Command::name)) .sorted(Comparator.comparing(Command::name))
.forEachOrdered(cmd -> { .forEachOrdered(cmd -> {