use of com.archyx.aureliumskills.api.event.ManaAbilityActivateEvent in project AureliumSkills by Archy-X.
the class ManaAbilityProvider method activate.
public void activate(Player player) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
int duration = getDuration(playerData);
ManaAbilityActivateEvent event = new ManaAbilityActivateEvent(player, mAbility, duration);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
manager.setActivated(player, mAbility, true);
// Mana ability specific behavior is run
onActivate(player, playerData);
consumeMana(player, playerData);
if (duration != 0) {
// Schedules stop
new BukkitRunnable() {
@Override
public void run() {
stop(player);
manager.setActivated(player, mAbility, false);
manager.setReady(player.getUniqueId(), mAbility, false);
}
}.runTaskLater(plugin, duration);
} else {
stop(player);
manager.setActivated(player, mAbility, false);
manager.setReady(player.getUniqueId(), mAbility, false);
}
}
Aggregations