Util [1.7-1.14.X] PluginCommandBuilder - Create plugin commands without registering in plugin.yml!

Discussion in 'Resources' started by Reflxction, Sep 23, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    Reflxction

    Have you ever been to the need of creating commands without having to use the plugin.yml? Perhaps you wanted to make your command and permission configurable, or even better, make users create their own commands!

    In any case, I'm sure this tiny utility will help you achieve your goal.

    Example usage:
    Code:
        @Override
        public void onEnable() {
            new PluginCommandBuilder("example", this)
                    .command(my CommandExecutor/TabExecutor)
                    .tab(my TabCompleter)
                    .description("Example command")
                    .usage("/example")
                    .aliases(Collections.singletonList("ex"))
                    .permission("myplugin.example")
                    .permissionMessage("You do not have permission to use this command!")
                    .register() // Must be called to register the command
                    .build(); // This will return a PluginCommand, in case it was needed.
        }
    The code above, will have the same exact effect of using a command in the plugin.yml, as in /help messages, in t abs, etc.

    Basically, all elements of a command in plugin.yml can be set using PluginCommandBuilder, hence it brings the same effect to its full extent.

    PluginCommandBuilder uses PluginCommandFactory, which is also a tiny part of this utility

    PluginCommandFactory: https://gist.github.com/ReflxctionDev/4fff4463f9c45c2a450f1618b2b7c98d
    PluginCommandBuilder: https://gist.github.com/ReflxctionDev/8ba26571e40ee0dda74648ccf82f9646

    Let me know what you think :)
     
Thread Status:
Not open for further replies.

Share This Page