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

    • 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. Does apply a root permission. If undesired, use the other constructor.
    • CommandRegistry

      public CommandRegistry(GeyserImpl geyser, org.incendo.cloud.CommandManager<GeyserCommandSource> cloud, boolean applyRootPermission)
      Creates a new CommandRegistry
      Parameters:
      geyser - the Geyser instance
      cloud - the cloud command manager to register commands to
      applyRootPermission - true if this registry should apply a permission to Geyser and Extension root commands. This currently exists because we want to retain the root command permission for Spigot, but don't want to add it yet to platforms like Velocity where we cannot natively specify a permission default. Doing so will break setups as players would suddenly not have the required permission to execute any Geyser commands.
  • 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.