Plugin API
The api allows you to integrate your plugin with KitPvP Plus.
Note
Certain parts of the plugin are not included in the api. They be being added however you will have to use the internal plugin to access them in the mean time
Tip
All of the methods and classes have taliored descriptions (Javadocs). You can use IntelliSense the view them inside your ide or navigate it's webpage to look at them
Setup
First of all you need to add the api as a dependency to your project
Dependency
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 7 |
|
Finally, add the following to your plugin.yml
:
1 |
|
API Access
You can now use the api! In our main class we can do this:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Player Data
You can access the data stored about players, such as kills, exp etcetera through a useful interface. To access you can do the following:
1 2 3 4 5 6 |
|
1 2 3 4 5 6 7 8 9 |
|
Info
You can actually get playerdata of offline players, however if they have never joined the server they will just have blank data
Event Listeners
The API usefully adds some bukkit events so you can run code when certain things happen
Example
Using bukkit events:
1 2 3 4 5 6 7 |
|
1 2 3 4 5 |
|
Event Class name | Description |
---|---|
AbilityActivateEvent |
Called when a player activates an event |
KitLoadEvent |
Called when someone loads the event |
StateChangeEvent |
Called when the player's state changes |
PlayerDataCreationEvent |
Called when playerdata is created |
Custom abilities
Though players are limited to the ablities that come with the plugin. However you create your own!
Creating your ability
First of all we need to create a new class for our ability. It also needs to extend the Ability
class
1 2 3 |
|
We're going to add a constructor to our class that looks something like this
1 2 3 |
|
Warning
The id of the ability must be unique. It will conflict with other abilities otherwise.
Next up, we need to add method that runs when the ability is activated. We can add this
1 2 3 4 |
|
The final thing to do is go into your main class and in the onEnable
method add the following line of code:
1 2 3 4 |
|
In the end, your ability class should look like this:
Example
Warning
If you just copy and paste this, please just read the code to understand what everything does. Please, for your own sake
1 2 3 4 5 6 7 8 9 10 11 |
|
Decreasing item amount
Similar to the TNT Shooter
ability in the default plugin, your ability can work where you have x
amount of items and decrease them every time they're used.
Essentially in your onActivate
method in your ability class, once you've called all your code you can add this:
1 2 3 4 5 |
|
Ability cooldowns
You can easily implement cooldowns into your ability with one line of code! This is similar to the Sonic
ability in the default plugin.
1 2 3 4 5 |
|
Tip
You can easily convert times using the TimeUnit
class in java. For example:
1 |
|
Locations
You can actually access the locations used in KitPvPPlus such as spawn and the arena!
Example
1 2 3 4 5 6 7 8 |
|
Config
You can access all data from the config files through the api
Danger
You cannot set data within the config files. Unless you go into the config instance, there is no way of accessing the raw config file
Example
1 2 3 4 |
|
Getting data from the other configs is pretty similar
Leaderboards
You can access information about leaderboards so you can intergrate them into your plugin and add features.
Example
Getting the leaderboard manager
1 2 3 4 |
|
We can now get, for example, the deaths leaderboard:
1 2 3 4 5 |
|
1 2 3 4 5 6 7 8 |
|
Kit manager
The kit manager allows you to interact with and create kits. You can access the kit manager by running:
1 |
|
1 2 3 4 5 |
|
Tip
You can get a list of all kits by doing
1 |
|
Finally, you can create kits my doing
1 2 3 |
|
Coming soon
Feature | ETA |
---|---|
Ability Manager | None |
Kit Manager | Done |
Found a problem? This documentation is open source and can be found here.