Custom Objectives
This guide will explain how to add your very own objective to XLTournaments.
Creating a custom objective is a fairly straight forward process. First of all, ensure you have the API dependency loaded into your project and set it as a depend in your plugin.yml file.
Create your objective class that extends XLObjective
. In this example, I will create a class called PlaceObjective
which will track block placement:
You will need to create a constructor matching the super class. Your IDE may prompt you to do so. Inside the super(...);
you will add your objective identifier. In this case, it's called "BLOCK_PLACE" and you'd use this in the tournament configuration.
Next we'll need to add the loadTournament
method, this will allow you to load any objective exclusive settings from each tournament configuration file:
Finally, we add our event listener (and method contents) to track block placement:
You do not need to register the events in this class as this is done by XLT internally in the super class.
We need to get all active tournaments which use the block place objective and using the canExecute
method we if the user is a participant and has finished the challenge (if applicable) and if they are in a disabled world. We can then add the score directly to the tournament passing the UUID of the player and the amount of points to add. We add 1 point in this example as this is represents one block broken.
Register the objective
Now we simply need to register the objective as shown below.
If your objective requires an external plugin (we will check if the plugin is enabled) then use:
Make sure XLTournaments has been added as a depend in your plugin.yml
to ensure it loads correctly.
Last updated