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

Auto_register_commands

Leonhard edited this page Aug 25, 2020 · 12 revisions

Dependencies

BungeeCord

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

Spigot

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

Adding to the required modules to the place you register your application as a SimplixApplication.

SimplixInstaller
        .instance()
        .register(
            getClass(),
            new CommonSimplixModule(),
            new DynamicCommandsSimplixModule(this),
            new DynamicListenersSimplixModule(this));

Now your command will be registered automatically

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) {
    //
  }
}