Skip to content

XPBoostAPI

milkwalk edited this page Jan 9, 2019 · 15 revisions

XPBoost api and how to use it.

Add XPBoost as dependency first through maven or directly as jar, then you are able to access XPBoostAPI. Most of the stuff is self-explanatory, but here are some notes anyways.

Checking if player has boost

XPBoostAPI.hasBoost(Player player)

Getting player's boost

XPBoostAPI.getBoost(Player player)

Will return players XPBoost or null if player doesn't have any active boost

Setting new boost

XPBoostAPI.setPlayerBoost(UUID id, double boost, int duration);

Will set a boost for a player, if player already has a boost and you are setting boost with the same multiplier, then the lenght of the boost is just being extended.

Duration is in seconds.

Example

XPBoost boost = XPBoostAPI.setPlayerBoost(uuid, 2.0, 300);

Conditions

This is an example how to set MCMMO condition to false (disable mcmmo experience for this boost)

XPBoost boost = XPBoostAPI.getBoost(player);
boost.putCondition(Condition.MCMMO, false);

Advanced options

TBA


More examples

public void customFunction(Player player){
    UUID id = player.getUniqueId();
    if(XPBoostAPI.hasBoost(id)){
        XPBoost xpb = XPBoostAPI.getBoost(id);
        System.out.println("Player boost: " + xpb.getBoost());
        System.out.println("Player boost duration: " + xpb.getBoostTime());
        System.out.println("Time remaining: (in seconds) " + xpb.getTimeRemaining());
        System.out.println("Boost end time (in miliseconds): " + xpb.getEndTime());
        ///xpb.clear(); //Clears/Removes Boost
    }
}

Clone this wiki locally