Class ScriptCommandRegistrar

java.lang.Object
org.skriptlang.skript.bukkit.command.custom.ScriptCommandRegistrar

public final class ScriptCommandRegistrar extends Object
Utility class for registering Brigadier commands at runtime through reflection. This avoids a full reload via Bukkit.reloadData(). However, that approach will be used if the reflection-based approach fails to load.
  • Constructor Details

    • ScriptCommandRegistrar

      public ScriptCommandRegistrar()
  • Method Details

    • init

      @Internal public static void init(org.bukkit.plugin.java.JavaPlugin plugin)
    • register

      public static void register(ScriptBrigadierCommand command)
      Adds the command to the registration queue. To finalize registration, the queue must be processed using processRegistrations().
      Parameters:
      command - The command to register.
      See Also:
    • processRegistrations

      public static void processRegistrations()
      Processes all pending registrations, synchronizing them with the server's command dispatcher.
      See Also:
    • unregister

      public static void unregister(ScriptBrigadierCommand command)
      Adds the command to the unregistration queue. To finalize unregistration, the queue must be processed using processUnregistrations().
      Parameters:
      command - The command to unregister.
      See Also:
    • processUnregistrations

      public static void processUnregistrations()
      Processes all pending unregistrations, synchronizing them with the server's command dispatcher.
      See Also:
    • getCommand

      @Nullable public static @Nullable ScriptBrigadierCommand getCommand(String command)
      Obtains a script command by its name.
      Parameters:
      command - The name of the command.
      Returns:
      The script command named command, or null if no script command with that name exists.
    • getCommands

      public static Set<ScriptBrigadierCommand> getCommands()
      Returns:
      All commands registered with this registrar.