mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Mark Command.Builder#permission(String, TriState) as experimental.
Improve javadoc and HelpCommand.
This commit is contained in:
parent
20d91cc201
commit
667486b95f
4 changed files with 13 additions and 5 deletions
|
|
@ -167,14 +167,16 @@ public interface Command {
|
|||
/**
|
||||
* 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.
|
||||
<p>
|
||||
* Extensions may instead listen for {@link GeyserRegisterPermissionsEvent} to register permissions, which
|
||||
* should be used if the same permission is required by multiple commands.
|
||||
* <p>
|
||||
* Extensions may instead listen for {@link GeyserRegisterPermissionsEvent} to register permissions,
|
||||
* especially if the same permission is required by multiple commands. Also see this event for TriState meanings.
|
||||
*
|
||||
* @param permission the permission node
|
||||
* @param defaultValue the node's default value
|
||||
* @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);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -39,7 +39,10 @@ import org.geysermc.geyser.api.util.TriState;
|
|||
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 defaultValue the default value of the node
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ package org.geysermc.geyser.command;
|
|||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
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.text.GeyserLocale;
|
||||
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.
|
||||
* A null value indicates that the permission node should not be registered whatsoever.
|
||||
* See {@link GeyserRegisterPermissionsEvent#register(String, TriState)} for TriState meanings.
|
||||
*/
|
||||
@Nullable
|
||||
private final TriState permissionDefault;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
|
|
@ -71,7 +72,7 @@ public class HelpCommand extends GeyserCommand {
|
|||
|
||||
this.commands.stream()
|
||||
.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()))
|
||||
.sorted(Comparator.comparing(Command::name))
|
||||
.forEachOrdered(cmd -> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue