Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.

Auto_register_commands

Nico edited this page Sep 17, 2020 · 12 revisions

Auto register commands

Dependencies

The extensions for the automatic command registration are located in platform-specific modules. The exact dependencies can be found below.

BungeeCord

<dependency>
    <groupId>dev.simplix</groupId>
    <artifactId>simplixcore-minecraft-bungeecord-dynamiccommands</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>provided</scope>
</dependency>

Spigot

<dependency>
    <groupId>dev.simplix</groupId>
    <artifactId>simplixcore-minecraft-spigot-dynamiccommands</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>provided</scope>
</dependency>

You need to pass an instance of DynamicCommandsSimplixModule to the register method:

SimplixInstaller
        .instance()
        .register(
            ExamplePlugin.class,
            new DynamicCommandsSimplixModule());

Now your command will be registered automatically, if it is a component which needs to be bound at DynamicCommandsSimplixModule. Example:

import dev.simplix.core.common.aop.Component;
import dev.simplix.core.minecraft.bungeecord.dynamiccommands.DynamicCommandsSimplixModule;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;

@Component(value = DynamicCommandsSimplixModule.class)
public class ExampleCommand extends Command {

  public ExampleCommand() {
    super("example");
  }

  @Override
  public void execute(CommandSender commandSender, String[] strings) {
    //
  }
}