Welcome to Episode Four of our Minecraft plugin development series.

Click here to see the third episode where I show you how to listen for any game events (actions) when making Minecraft plugins.


In this episode, we’re going to cover:

  • Commands — Making a custom command with CommandExecutor interface.
  • Registering commands — Using plugin.yml and the getCommand() method to register a command.
  • Tab completion — Making commands tab complete.


Source Codes:




Registering Command In Plugin.Yml

Before creating any command, you need to register it in plugin.yml file so that the server can recognize it. See the above video for more instructions or the link to plugin.yml tutorial for all available options.

Here is an example of the /cow command which can also be run with the /cowcannon alias:


Implementing Your Command

Then create a new class and make it implement CommandExecutor. Inside that, implement the required onCommand() method taking the following parameters:

The method returns true or false. Return true if the command was run properly, otherwise return false so that the server can display the “usage” message from your plugin.yml, if specified.

Then implement your code. You will see an example of this in the video above. The most important part is the args[] parameter, which splits everything following the command label (/cow). Such as /cow hello world will give you “hello” as args[0] and “world” as args[1], and args.length will return 2 because there are two arguments.


Adding Tab Completion

You can optionally implement the TabExecutor for the command and implement the onTabComplete() method. Return “null” in the method for the server to suggest all online player names. If you want to disable tab completion, return a new empty array list. You can create a switch statement or if-conditions depending on the args[] length to tab complete different parts of the command.



Registering Command Executor

Finally, don’t forget to get the command from the server and set its executor to your own class.


Final Words

Creating Minecraft plugins can be confusing, with most YouTube tutorials being painfully outdated, disorganized and offering no live support.

If you want to learn from the best of the pack and create truly customized plugins, check out Project Orion.

It’s a full fledged training tried and tested by 2,000+ people showing step-by-step on how to make plugins, advanced systems (minigames, custom mobs, antipiracy, dungeons, claims etc.) and best yet, I am doing live calls multiple times each week and connect with you in our community to answer any and all questions you have.

It’s just so much better experience than any blog post or video since I can pour my time and heart into it with greater depth and our platform is custom coded with features we need for it specifically. Click here to learn more!