Search in sources :

Example 6 with AbilityData

use of com.archyx.aureliumskills.data.AbilityData in project AureliumSkills by Archy-X.

the class ChargedShot method onToggle.

@EventHandler
public void onToggle(PlayerInteractEvent event) {
    if (blockDisabled(MAbility.CHARGED_SHOT))
        return;
    Player player = event.getPlayer();
    if (blockAbility(player))
        return;
    ItemStack item = event.getItem();
    if (item == null)
        return;
    if (item.getType() != Material.BOW)
        return;
    if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData == null)
            return;
        if (playerData.getManaAbilityLevel(MAbility.CHARGED_SHOT) == 0)
            return;
        Locale locale = playerData.getLocale();
        AbilityData abilityData = playerData.getAbilityData(MAbility.CHARGED_SHOT);
        if (abilityData.getInt("cooldown") == 0) {
            if (!abilityData.getBoolean("enabled")) {
                // Toggle on
                abilityData.setData("enabled", true);
                plugin.getAbilityManager().sendMessage(player, Lang.getMessage(ManaAbilityMessage.CHARGED_SHOT_ENABLE, locale));
            } else {
                // Toggle off
                abilityData.setData("enabled", false);
                plugin.getAbilityManager().sendMessage(player, Lang.getMessage(ManaAbilityMessage.CHARGED_SHOT_DISABLE, locale));
            }
            abilityData.setData("cooldown", 8);
        }
    }
}
Also used : Locale(java.util.Locale) Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) PlayerData(com.archyx.aureliumskills.data.PlayerData) AbilityData(com.archyx.aureliumskills.data.AbilityData) EventHandler(org.bukkit.event.EventHandler)

Aggregations

AbilityData (com.archyx.aureliumskills.data.AbilityData)6 PlayerData (com.archyx.aureliumskills.data.PlayerData)5 StatModifier (com.archyx.aureliumskills.modifier.StatModifier)4 Skill (com.archyx.aureliumskills.skills.Skill)4 KeyIntPair (com.archyx.aureliumskills.util.misc.KeyIntPair)4 IOException (java.io.IOException)4 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3 AbstractAbility (com.archyx.aureliumskills.ability.AbstractAbility)2 PlayerDataLoadEvent (com.archyx.aureliumskills.data.PlayerDataLoadEvent)2 Stat (com.archyx.aureliumskills.stats.Stat)2 File (java.io.File)2 Locale (java.util.Locale)2 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)2 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1 ItemStack (org.bukkit.inventory.ItemStack)1 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)1