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);
}
}
}
Aggregations