Rafoudiablol's Command API 2019-08-09

Create commands with automatic arguments management.

  1. Rafoudiablol
    Tested Minecraft Versions:
    • 1.13
    • 1.14
    Overview:

    Code (Java):
    @Executor
    public void doAnotherCommand(ConsoleCommandSender sender, int firstArg, String secondArg)
    {
        for(int i = 0; i < firstArg; i++)
        {
            sender.sendMessage(secondArg);
        }
    }
    Code (Text):
    > /repeat 10 Hello
    > Hello
    > Hello
    > Hello
    > Hello
    > Hello
    > Hello
    > Hello
    > Hello
    > Hello
    > Hello

    Usage


    You just have to inherit from this class and annotate a function with the annotation @Executor. You can name the function as you want. You can also have multiple function with @Executors, but each need an unique signature. You can also optionnaly return a boolean like onCommand, also any other return type is siltenlty ignored. You can also return just void, which will return true from onCommand.

    Code (Java):
    import net.rafoudiablol.command.PluginCommandExecutor;
    import net.rafoudiablol.command.mapper.Executor;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.entity.Player;

    /**
    *  As a player,
    *
    *      /my_command_name
    *
    *
    *  As a console,
    *
    *      /my_command_name 10 SpamMe!
    */


    public class TestExecutor extends PluginCommandExecutor {

        @Executor
        public void doMyCommand(Player player) {

            player.sendMessage("Hello there!");
        }

        @Executor
        public void doAnotherCommand(ConsoleCommandSender sender, int firstArg, String secondArg) {

            for(int i = 0; i < firstArg; i++) {

                sender.sendMessage(secondArg);
            }
        }
    }
    PluginCommandExecutor is a CommandExecutor.

    Installation instruction

    Import the JAR into your project.
    You don't need to put the JAR into the plugins/ folder.

    Dependencies

    spigot-1.14.4 (not included)
    Reflections (included)

    • wrap end of the command (with spaces) into one argument
    • smart argument binding
    • more types
      • player
        • uuid
        • pseudo
      • other primitive types
        • long
        • float
        • boolean
      • ...
    • policy
      • positive number
      • negative number
      • custom
      • ...
    Works only with int and String for now.

    -----------------------------------------------------------------------