Create Your Own Boosts & Buffs

Down below you will see how you can create your very own boosts using the API!

You can create boosts by registering the boost or not

With Registering ->

  1. Create a new Class that extends PetBuffRegister .

public class ExampleBuff extends PetBuffRegister {
  1. Add these methods to it

    @Override
    public String getBuffName() {
        return "yourbuffname";
    }


    @Override
    public void onActivatePet(Player player) {

    }

    @Override
    public void onDeactivatePet(Player player) {

    }

    @EventHandler
    public void onBoost(YourCurrencyOrOtherEvents event) {
                Player player = event.getPlayer();
                if (RivalPetsAPI.getApi().hasBuff(player,getBuffName())){
                    RivalPetsAPI.getApi().addExperience(player,getBuffName());
                    double totalBoost = RivalPetsAPI.getApi().getBuffBoost(player,getBuffName())));
        }
    }
  1. After your done in your onEnable() you will need to register the buff like this, don't worry about registering Listeners that is handled by RivalPets and this way your buff will show up in /pets buffs.

if (Bukkit.getPluginManager().getPlugin("RivalPets") != null) {
RivalPetsAPI.getApi().registerBuff(new ExampleBuff (),"YourPluginName");
}
  1. Make sure in your plugin.yml to add RivalPets to either soft-depend or depend

Without Registering ->

In any listeners or anywhere in your code you can do:

Note: this way you will have to register your events

@EventHandler
    public void onBoost(YourCurrencyOrOtherEvents event) {
                Player player = event.getPlayer();
                String buffName = "yourdesiredbuff";
                if (RivalPetsAPI.getApi().hasBuff(player,buffName )){
                RivalPetsAPI.getApi().addExperience(player,buffName );    
                double totalBoost = RivalPetsAPI.getApi().getBuffBoost(player,buffName)));
        }
    }

Last updated