- Joined
- Nov 12, 2020
- Messages
- 67
- Reaction score
- 36
- Points
- 18
How to add custom commands to Arcturus
This tutorial assumes you've set up the Arcturus plugin environment as described here.
In this tutorial, we will be creating a new command and registering it. The command will only send an alert to the triggering Habbo.
Step 1: Creating a new java file.
First of creating a new file and name it CustomCommand. This is the code file in which we will be writing our code to handle our command.
Step 2: Extending the Command class.
Have the CustomCommand class extend the Command class.
Because Arcturus must know that we are dealing with a command we have to extend the Command class.
Step 3: Implementing the super constructor.
If you have enabled error reporting IntelliJ will tell you that you must implement the constructor. This will create a constructor with the same arguments as the super constructor. Ignore the error for now.
Now as we have to create a new instance we must implement a constructor as the superclass also implements a constructor and must call the super constructor. We can do that like this:
To add the constructor add:
The first argument is the permission node that will be checked to make sure the Habbo that runs the command is actually allowed to do so. You can put null ("Without quotes") to disable this check.
The second argument is of the type String[] which contains all the keys that will trigger this command. This is without the : part. In our case, we will be running the command via :customcommand so we specify customcommand. You can add more keys as you wish.
Step 5: Adding our command handling.
Override the
IntelliJ will tell you that you must implement the handle() function. Press alt+enter and choose to Implement Methods
Step 6: Handling commands.
The handle function will be called whenever a Habbo runs our command. This is the function in which you can implement your logic.
For now, we will just send an alert to the Habbo by sending the alert packet which is as follows:
The function must return whether the command was successfully executed either with true or false
Your CommandClass.java file will look something like this:
Step 7: Registering our command.
To register our command go to your plugin class and in the constructor add:
This tutorial assumes you've set up the Arcturus plugin environment as described here.
In this tutorial, we will be creating a new command and registering it. The command will only send an alert to the triggering Habbo.
Step 1: Creating a new java file.
First of creating a new file and name it CustomCommand. This is the code file in which we will be writing our code to handle our command.
Step 2: Extending the Command class.
Have the CustomCommand class extend the Command class.
Because Arcturus must know that we are dealing with a command we have to extend the Command class.
Step 3: Implementing the super constructor.
If you have enabled error reporting IntelliJ will tell you that you must implement the constructor. This will create a constructor with the same arguments as the super constructor. Ignore the error for now.
Now as we have to create a new instance we must implement a constructor as the superclass also implements a constructor and must call the super constructor. We can do that like this:
To add the constructor add:
The first argument is the permission node that will be checked to make sure the Habbo that runs the command is actually allowed to do so. You can put null ("Without quotes") to disable this check.
The second argument is of the type String[] which contains all the keys that will trigger this command. This is without the : part. In our case, we will be running the command via :customcommand so we specify customcommand. You can add more keys as you wish.
Step 5: Adding our command handling.
Override the
IntelliJ will tell you that you must implement the handle() function. Press alt+enter and choose to Implement Methods
Step 6: Handling commands.
The handle function will be called whenever a Habbo runs our command. This is the function in which you can implement your logic.
For now, we will just send an alert to the Habbo by sending the alert packet which is as follows:
The function must return whether the command was successfully executed either with true or false
Your CommandClass.java file will look something like this:
Step 7: Registering our command.
To register our command go to your plugin class and in the constructor add: