Search in sources :

Example 21 with PlayerData

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

the class ChargedShot method activationListener.

@EventHandler
public void activationListener(EntityShootBowEvent event) {
    if (blockDisabled(MAbility.CHARGED_SHOT))
        return;
    if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();
        if (blockAbility(player))
            return;
        PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
        if (playerData == null)
            return;
        if (playerData.getAbilityData(MAbility.CHARGED_SHOT).getBoolean("enabled")) {
            if (playerData.getManaAbilityLevel(MAbility.CHARGED_SHOT) == 0)
                return;
            ManaAbilityManager manager = plugin.getManaAbilityManager();
            int cooldown = manager.getPlayerCooldown(player.getUniqueId(), MAbility.SHARP_HOOK);
            if (cooldown == 0) {
                playerData.getMetadata().put("charged_shot_projectile", event.getProjectile());
                playerData.getMetadata().put("charged_shot_force", event.getForce());
                activate(player);
            } else {
                if (manager.getErrorTimer(player.getUniqueId(), MAbility.SHARP_HOOK) == 0) {
                    Locale locale = playerData.getLocale();
                    plugin.getAbilityManager().sendMessage(player, TextUtil.replace(Lang.getMessage(ManaAbilityMessage.NOT_READY, locale), "{cooldown}", NumberUtil.format1((double) (cooldown) / 20)));
                    manager.setErrorTimer(player.getUniqueId(), MAbility.SHARP_HOOK, 2);
                }
            }
        }
    }
}
Also used : Locale(java.util.Locale) Player(org.bukkit.entity.Player) PlayerData(com.archyx.aureliumskills.data.PlayerData) EventHandler(org.bukkit.event.EventHandler)

Example 22 with PlayerData

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

the class BlockLootHandler method onBreak.

@EventHandler(priority = EventPriority.HIGH)
public void onBreak(BlockBreakEvent event) {
    if (!OptionL.isEnabled(skill))
        return;
    if (event.isCancelled())
        return;
    Block block = event.getBlock();
    if (getSource(block) == null)
        return;
    Player player = event.getPlayer();
    if (blockAbility(player))
        return;
    if (player.getGameMode() != GameMode.SURVIVAL) {
        // Only drop loot in survival mode
        return;
    }
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    if (playerData == null)
        return;
    Source originalSource = getSource(block);
    LootTable table = plugin.getLootTableManager().getLootTable(skill);
    if (table == null)
        return;
    for (LootPool pool : table.getPools()) {
        // Calculate chance for pool
        double chance = getChance(pool, playerData);
        LootDropCause cause = getCause(pool);
        // Select pool and give loot
        if (selectBlockLoot(pool, player, chance, originalSource, event, cause)) {
            break;
        }
    }
}
Also used : LootTable(com.archyx.aureliumskills.loot.LootTable) Player(org.bukkit.entity.Player) LootDropCause(com.archyx.aureliumskills.api.event.LootDropCause) Block(org.bukkit.block.Block) LootPool(com.archyx.aureliumskills.loot.LootPool) PlayerData(com.archyx.aureliumskills.data.PlayerData) Source(com.archyx.aureliumskills.source.Source) EventHandler(org.bukkit.event.EventHandler)

Example 23 with PlayerData

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

the class ManaAbilityProvider method stop.

public void stop(Player player) {
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    if (playerData == null)
        return;
    // Mana ability specific stop behavior is run
    onStop(player, playerData);
    // Apply cooldown
    manager.setPlayerCooldown(player, mAbility);
    // Send stop message if applicable
    if (stopMessage != null) {
        plugin.getAbilityManager().sendMessage(player, Lang.getMessage(stopMessage, plugin.getLang().getLocale(player)));
    }
}
Also used : PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 24 with PlayerData

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

the class Leveler method setXp.

// Method for setting xp with a defined amount
public void setXp(Player player, Skill skill, double amount) {
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    // Checks if player has a skill profile for safety
    if (playerData != null) {
        double originalAmount = playerData.getSkillXp(skill);
        // Sets Xp
        playerData.setSkillXp(skill, amount);
        // Check if player leveled up
        checkLevelUp(player, skill);
        // Sends action bar message
        plugin.getActionBar().sendXpActionBar(player, skill, amount - originalAmount);
        // Sends boss bar if enabled
        sendBossBar(player, skill, playerData);
    }
}
Also used : PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 25 with PlayerData

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

the class SkillInfoItem method getAbilityLevelsLore.

private String getAbilityLevelsLore(Skill skill, PlayerData playerData, Locale locale) {
    StringBuilder abilityLevelsLore = new StringBuilder();
    if (skill.getAbilities().size() == 5) {
        String levelsMessage = Lang.getMessage(MenuMessage.ABILITY_LEVELS, locale);
        int num = 1;
        List<Ability> abilities = new ArrayList<>();
        for (Supplier<Ability> abilitySupplier : skill.getAbilities()) {
            abilities.add(abilitySupplier.get());
        }
        abilities.sort(Comparator.comparingInt(a -> plugin.getAbilityManager().getUnlock(a)));
        for (Ability ability : abilities) {
            if (plugin.getAbilityManager().isEnabled(ability)) {
                if (playerData.getAbilityLevel(ability) > 0) {
                    int abilityLevel = playerData.getAbilityLevel(ability);
                    levelsMessage = TextUtil.replace(levelsMessage, "{ability_" + num + "}", TextUtil.replace(Lang.getMessage(MenuMessage.ABILITY_LEVEL_ENTRY, locale), "{ability}", ability.getDisplayName(locale), "{level}", RomanNumber.toRoman(playerData.getAbilityLevel(ability)), "{info}", TextUtil.replace(ability.getInfo(locale), "{value}", NumberUtil.format1(plugin.getAbilityManager().getValue(ability, abilityLevel)), "{value_2}", NumberUtil.format1(plugin.getAbilityManager().getValue2(ability, abilityLevel)))));
                } else {
                    levelsMessage = TextUtil.replace(levelsMessage, "{ability_" + num + "}", TextUtil.replace(Lang.getMessage(MenuMessage.ABILITY_LEVEL_ENTRY_LOCKED, locale), "{ability}", ability.getDisplayName(locale)));
                }
            } else {
                levelsMessage = TextUtil.replace(levelsMessage, "\\n  {ability_" + num + "}", "", "{ability_" + num + "}", "");
            }
            num++;
        }
        abilityLevelsLore.append(levelsMessage);
    }
    return abilityLevelsLore.toString();
}
Also used : MAbility(com.archyx.aureliumskills.mana.MAbility) Ability(com.archyx.aureliumskills.ability.Ability) MenuMessage(com.archyx.aureliumskills.lang.MenuMessage) java.util(java.util) ItemMeta(org.bukkit.inventory.meta.ItemMeta) OptionL(com.archyx.aureliumskills.configuration.OptionL) Player(org.bukkit.entity.Player) Supplier(java.util.function.Supplier) MessageKey(com.archyx.aureliumskills.lang.MessageKey) TextUtil(com.archyx.aureliumskills.util.text.TextUtil) Option(com.archyx.aureliumskills.configuration.Option) AureliumSkills(com.archyx.aureliumskills.AureliumSkills) Lang(com.archyx.aureliumskills.lang.Lang) ImmutableList(com.google.common.collect.ImmutableList) MAbility(com.archyx.aureliumskills.mana.MAbility) Skill(com.archyx.aureliumskills.skills.Skill) ItemUtils(com.archyx.aureliumskills.util.item.ItemUtils) RomanNumber(com.archyx.aureliumskills.util.math.RomanNumber) ManaAbilityManager(com.archyx.aureliumskills.mana.ManaAbilityManager) PlaceholderAPI(me.clip.placeholderapi.PlaceholderAPI) ItemStack(org.bukkit.inventory.ItemStack) Stat(com.archyx.aureliumskills.stats.Stat) NumberUtil(com.archyx.aureliumskills.util.math.NumberUtil) PlayerData(com.archyx.aureliumskills.data.PlayerData) ChatColor(org.bukkit.ChatColor) Ability(com.archyx.aureliumskills.ability.Ability) ManaAbilityMessage(com.archyx.aureliumskills.lang.ManaAbilityMessage)

Aggregations

PlayerData (com.archyx.aureliumskills.data.PlayerData)111 Player (org.bukkit.entity.Player)54 EventHandler (org.bukkit.event.EventHandler)43 Locale (java.util.Locale)27 ItemStack (org.bukkit.inventory.ItemStack)25 Skill (com.archyx.aureliumskills.skills.Skill)15 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)10 Stat (com.archyx.aureliumskills.stats.Stat)9 AttributeInstance (org.bukkit.attribute.AttributeInstance)8 PlayerLootDropEvent (com.archyx.aureliumskills.api.event.PlayerLootDropEvent)7 StatModifier (com.archyx.aureliumskills.modifier.StatModifier)7 Material (org.bukkit.Material)7 LivingEntity (org.bukkit.entity.LivingEntity)7 KeyIntPair (com.archyx.aureliumskills.util.misc.KeyIntPair)6 AureliumSkills (com.archyx.aureliumskills.AureliumSkills)5 OptionL (com.archyx.aureliumskills.configuration.OptionL)5 AbilityData (com.archyx.aureliumskills.data.AbilityData)5 File (java.io.File)5 IOException (java.io.IOException)5 PlayerDataLoadEvent (com.archyx.aureliumskills.data.PlayerDataLoadEvent)4