Search in sources :

Example 1 with ManaAbilityActivateEvent

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);
    }
}
Also used : ManaAbilityActivateEvent(com.archyx.aureliumskills.api.event.ManaAbilityActivateEvent) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Aggregations

ManaAbilityActivateEvent (com.archyx.aureliumskills.api.event.ManaAbilityActivateEvent)1 PlayerData (com.archyx.aureliumskills.data.PlayerData)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1