-
-
Notifications
You must be signed in to change notification settings - Fork 9
How to create custom kits
In this tutorial, we will explain how to use the latest API version for developers in order to create your own kits.
We will assume that this is not your first Java programming session with the bukkit API so as not to waste time going back over details like : how to install an IDE as eclipse and how to create its first bukkit plugin. There's already a lot of really good tutorials on the internet for that.
First of all, you will need to add USW-DEV-API.jar to the Librairies of your plugin if it's not already done.
Eclipse Path : Right click on your Java Project → Build Path → Configure Build Path → Librairies → Add External JARs...
Then, you can create a new class with your kit's name. In this tutorial, we will take as example the builder kit, really easy to understand for beginners.
Now that you've created your class, you can extend it with SheepWarsKit located at fr.asynchronous.sheepwars.api.SheepWarsKit, then add the constructor to your class.
It should look something like this :
public class BuilderKit extends SheepWarsKit {
public BuilderKit() {
super(id, name, freeKit, icon, levels)
}
}A strong description of each constructor is available thanks to the javadocs.
About the last argument (levels), you should know that the kits API allows you to create kits with different levels. By 'levels' we mean improvements. For example (if a kit has several coded levels), players who have unlocked the builder kit at level 1 can continue to pay to improve it further !
Each kit needs at least one level (this is the one which players unlock when they first buy the kit).
To create a new level for a kit, you will need to create a new class which extends SheepWarsKitLevel located at fr.asynchronous.core.api.SheepWarsKit.SheepWarsKitLevel. We strongly advise you to create each levels class of a kit in the same class than the kit.
Let's go back to our example which now looks like this:
public class BuilderKit extends SheepWarsKit {
public BuilderKit() {
super(id, name, freeKit, icon, levels);
}
public static class BuilderKitLevel0 extends SheepWarsKitLevel {
public BuilderKitLevel0() {
super(levelName, description, permission, price, requiredWins);
}
@Override
public boolean onEquip(Player player) {
}
}
}You can see that we saved time by directly adding the constructor & methods. The method onEquip([...]) is self-explanatory but you can always check the javadocs.
Regarding our main idea (do the builder kit):
-
onEquip([...])We just want to give to the player special blocks. We don't want to edit his default inventory (wooden sword, leather armor, etc.) so wereturn true.
player.getInventory().setItem(2, new ItemStack(Material.BRICK, 5));
player.getInventory().setItem(3, new ItemStack(Material.SAND, 5, (short) 1));
player.getInventory().setItem(4, new ItemStack(Material.ANVIL, 5));
return true;Moreover, the SheepWarsKitLevel class implements org.bukkit.event.Listener so you can add events to be triggered for each levels.
→ BetterBowKit is a good example for this.
You can have a look at the final class BuilderKit here.
Finally, to register your kit, simply use SheepWarsAPI.registerKit(<Instance of your kit class>, <Your plugin instance>);.
To Remember : All registred kits are automatically put in the kits inventory.
If you have any question, feel free to contact us on Twitter. It will be a pleasure to help you to use our product.
Have a good day/night !
- If you find any bugs or issues, just create a new bug report on github and it'll be fixed as soon as possible.
- Have any suggestions? Leave them in a new feature request.
- Introduction ✔️
- SheepWars API ✏️
- Calendar events ✏️
- Custom events ✔️
- Player data ✏️
- Item builder ✏️
- Game state ✏️
- Language ✏️
- Team manager ✏️
- If you find any bugs or issues, just create a new bug report on github and it'll be fixed as soon as possible.
- Have any suggestions? Leave them in a new feature request.