-
-
Notifications
You must be signed in to change notification settings - Fork 9
How to create custom boosters
In this tutorial, we will explain how to use the latest API version for developers in order to create your own boosters.
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 booster's name. In this tutorial, we will take as example the more sheep booster.
Now that you've created your class, you can extend it with SheepWarsBooster located at fr.asynchronous.sheepwars.core.booster.SheepWarsBooster, then add the default methods & constructor to your class.
It should look something like this :
public class MoreSheepBooster extends SheepWarsBooster
{
public MoreSheepBooster() {
super(name, displayColor, duration);
}
@Override
public boolean onStart(final Player player, final TeamManager team) {
return true;
}
@Override
public void onFinish() {
// Do nothing
}
}A strong description of each method & constructor is available thanks to the javadocs.
Regarding our example :
-
onStart([...])The more sheep booster is special because it is an instant booster. We mean that its duration must be 0. Indeed, when activated, it only gives one sheep to the players in the shooter team. It gives no effect that lasts in time. So we just need to give one sheep to every player in the shooter team.
for (final Player teamPlayer : team.getOnlinePlayers()) {
SheepWarsSheep.giveRandomSheep(teamPlayer);
}
return true;-
onFinish([...])As the effect of this booster is instantaneous, we have nothing to do when it ends. Also, note that it ends as fast as it starts and so we could give the sheep either in the first method or in this one. It wouldn't change anything.
// Do nothingYou can have a look at the final class MoreSheepBooster here.
Moreover, some trickier booster classes are available in the code section.
Finally, to register your booster, simply use SheepWarsAPI.registerBooster(<Instance of your booster class>);
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.