Class CommandRegistry

java.lang.Object
org.geysermc.geyser.command.CommandRegistry
All Implemented Interfaces:
org.geysermc.geyser.api.event.EventRegistrar

public class CommandRegistry extends Object implements org.geysermc.geyser.api.event.EventRegistrar
Registers all built-in and extension commands to the given Cloud CommandManager.

Fires GeyserDefineCommandsEvent upon construction.

Subscribes to GeyserRegisterPermissionsEvent upon construction. A new instance of this class (that registers the same permissions) shouldn't be created until the previous instance is unsubscribed from the event.

  • Field Details

    • STANDALONE_COMMAND_MANAGER

      public static final boolean STANDALONE_COMMAND_MANAGER
    • geyser

      protected final GeyserImpl geyser
    • permissionDefaults

      protected final Map<String,org.geysermc.geyser.api.util.TriState> permissionDefaults
      Map containing only permissions that have been registered with a default value
  • Constructor Details

    • CommandRegistry

      public CommandRegistry(GeyserImpl geyser, org.incendo.cloud.CommandManager<GeyserCommandSource> cloud)
      Creates a new CommandRegistry
      Parameters:
      geyser - the Geyser instance
      cloud - the cloud command manager to register commands to
  • Method Details

    • rootCommands

      public @NonNull Collection<String> rootCommands()
      Returns:
      an immutable view of the root commands registered to this command registry
    • register

      protected void register(GeyserCommand command, Map<String,GeyserCommand> commands)
    • onRegisterPermissions

      protected void onRegisterPermissions(org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionsEvent event)
    • hasPermission

      public boolean hasPermission(GeyserCommandSource source, String permission)
    • description

      public @NonNull String description(@NonNull String command, @NonNull String locale)
      Returns the description of the given command
      Parameters:
      command - the root command node
      locale - the ideal locale that the description should be in
      Returns:
      a description if found, otherwise an empty string. The locale is not guaranteed.
    • runCommand

      public void runCommand(@NonNull GeyserCommandSource source, @NonNull String command)
      Dispatches a command into cloud and handles any thrown exceptions. This method may or may not be blocking, depending on the ExecutionCoordinator in use by cloud.
    • suggestionsFor

      public org.incendo.cloud.suggestion.Suggestions<GeyserCommandSource,? extends org.incendo.cloud.suggestion.Suggestion> suggestionsFor(GeyserCommandSource source, String input)
    • export

      public void export(GeyserSession session, List<org.cloudburstmc.protocol.bedrock.data.command.CommandData> bedrockCommands, Set<String> knownAliases)