Реєстрація субкоманд
src/main/java/com/jodexindustries/testaddon/commands/FirstCommand.java
import com.jodexindustries.donatecase.api.data.subcommand.SubCommandExecutor;
import com.jodexindustries.donatecase.api.data.subcommand.SubCommandTabCompleter;
import com.jodexindustries.donatecase.api.platform.DCCommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class FirstCommand implements SubCommandExecutor, SubCommandTabCompleter {
@Override
public boolean execute(DCCommandSender sender, @NotNull String label, String[] args) {
sender.sendMessage("First command");
return true;
}
@Override
public List<String> getTabCompletions(@NotNull DCCommandSender sender, @NotNull String label, String[] args) {
return new ArrayList<>();
}
}
src/main/java/com/jodexindustries/testaddon/MainAddon.java
import com.jodexindustries.donatecase.api.DCAPI;
import com.jodexindustries.donatecase.api.addon.InternalJavaAddon;
import com.jodexindustries.donatecase.api.data.subcommand.SubCommand;
import com.jodexindustries.donatecase.api.data.subcommand.SubCommandType;
import com.jodexindustries.testaddon.commands.FirstCommand;
public class MainAddon extends InternalJavaAddon {
private final DCAPI api = DCAPI.getInstance();
@Override
public void onEnable() {
FirstCommand executor = new FirstCommand();
SubCommand first = SubCommand.builder()
.name("test")
.addon(this)
.permission(SubCommandType.PLAYER.permission)
.executor(executor)
.tabCompleter(executor)
.args(new String[]{"(test)", "(test2)"})
.description("This is cool command!")
.build();
api.getSubCommandManager().register(first);
}
}