Search in sources :

Example 1 with Ability

use of com.archyx.aureliumskills.ability.Ability 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)

Example 2 with Ability

use of com.archyx.aureliumskills.ability.Ability in project AureliumSkills by Archy-X.

the class Leveler method getLevelUpMessage.

private String getLevelUpMessage(Player player, PlayerData playerData, Skill skill, int newLevel, Locale locale, List<Reward> rewards) {
    String message = TextUtil.replace(Lang.getMessage(LevelerMessage.LEVEL_UP, locale), "{skill}", skill.getDisplayName(locale), "{old}", RomanNumber.toRoman(newLevel - 1), "{new}", RomanNumber.toRoman(newLevel));
    if (plugin.isPlaceholderAPIEnabled()) {
        message = PlaceholderAPI.setPlaceholders(player, message);
    }
    StringBuilder rewardMessage = new StringBuilder();
    for (Reward reward : rewards) {
        rewardMessage.append(reward.getChatMessage(player, locale, skill, newLevel));
    }
    // Ability unlocks and level ups
    StringBuilder abilityUnlockMessage = new StringBuilder();
    StringBuilder abilityLevelUpMessage = new StringBuilder();
    for (Ability ability : plugin.getAbilityManager().getAbilities(skill, newLevel)) {
        if (plugin.getAbilityManager().isEnabled(ability)) {
            if (plugin.getAbilityManager().getUnlock(ability) == newLevel) {
                abilityUnlockMessage.append(TextUtil.replace(Lang.getMessage(LevelerMessage.ABILITY_UNLOCK, locale), "{ability}", ability.getDisplayName(locale)));
            } else {
                abilityLevelUpMessage.append(TextUtil.replace(Lang.getMessage(LevelerMessage.ABILITY_LEVEL_UP, locale), "{ability}", ability.getDisplayName(locale), "{level}", RomanNumber.toRoman(playerData.getAbilityLevel(ability))));
            }
        }
    }
    message = TextUtil.replace(message, "{stat_level}", rewardMessage.toString(), "{ability_unlock}", abilityUnlockMessage.toString(), "{ability_level_up}", abilityLevelUpMessage.toString());
    // Mana ability unlocks and level ups
    StringBuilder manaAbilityUnlockMessage = new StringBuilder();
    StringBuilder manaAbilityLevelUpMessage = new StringBuilder();
    MAbility mAbility = plugin.getManaAbilityManager().getManaAbility(skill, newLevel);
    if (mAbility != null) {
        if (plugin.getAbilityManager().isEnabled(mAbility)) {
            if (plugin.getManaAbilityManager().getUnlock(mAbility) == newLevel) {
                manaAbilityUnlockMessage.append(TextUtil.replace(Lang.getMessage(LevelerMessage.MANA_ABILITY_UNLOCK, locale), "{mana_ability}", mAbility.getDisplayName(locale)));
            } else {
                manaAbilityLevelUpMessage.append(TextUtil.replace(Lang.getMessage(LevelerMessage.MANA_ABILITY_LEVEL_UP, locale), "{mana_ability}", mAbility.getDisplayName(locale), "{level}", RomanNumber.toRoman(playerData.getManaAbilityLevel(mAbility))));
            }
        }
    }
    message = TextUtil.replace(message, "{mana_ability_unlock}", manaAbilityUnlockMessage.toString(), "{mana_ability_level_up}", manaAbilityLevelUpMessage.toString());
    // Build money rewards
    StringBuilder moneyRewardMessage = new StringBuilder();
    double totalMoney = 0;
    // Legacy system
    if (plugin.isVaultEnabled()) {
        if (OptionL.getBoolean(Option.SKILL_MONEY_REWARDS_ENABLED)) {
            double base = OptionL.getDouble(Option.SKILL_MONEY_REWARDS_BASE);
            double multiplier = OptionL.getDouble(Option.SKILL_MONEY_REWARDS_MULTIPLIER);
            totalMoney += base + (multiplier * newLevel * newLevel);
        }
    }
    // New rewards
    for (MoneyReward reward : plugin.getRewardManager().getRewardTable(skill).searchRewards(MoneyReward.class, newLevel)) {
        totalMoney += reward.getAmount();
    }
    if (totalMoney > 0) {
        NumberFormat nf = new DecimalFormat("#.##");
        moneyRewardMessage.append(TextUtil.replace(Lang.getMessage(LevelerMessage.MONEY_REWARD, locale), "{amount}", nf.format(totalMoney)));
    }
    message = TextUtil.replace(message, "{money_reward}", moneyRewardMessage.toString());
    return message.replaceAll("(\\u005C\\u006E)|(\\n)", "\n");
}
Also used : MAbility(com.archyx.aureliumskills.mana.MAbility) Ability(com.archyx.aureliumskills.ability.Ability) DecimalFormat(java.text.DecimalFormat) MAbility(com.archyx.aureliumskills.mana.MAbility) MoneyReward(com.archyx.aureliumskills.rewards.MoneyReward) CommandReward(com.archyx.aureliumskills.rewards.CommandReward) MoneyReward(com.archyx.aureliumskills.rewards.MoneyReward) Reward(com.archyx.aureliumskills.rewards.Reward) NumberFormat(java.text.NumberFormat)

Aggregations

Ability (com.archyx.aureliumskills.ability.Ability)2 MAbility (com.archyx.aureliumskills.mana.MAbility)2 AureliumSkills (com.archyx.aureliumskills.AureliumSkills)1 Option (com.archyx.aureliumskills.configuration.Option)1 OptionL (com.archyx.aureliumskills.configuration.OptionL)1 PlayerData (com.archyx.aureliumskills.data.PlayerData)1 Lang (com.archyx.aureliumskills.lang.Lang)1 ManaAbilityMessage (com.archyx.aureliumskills.lang.ManaAbilityMessage)1 MenuMessage (com.archyx.aureliumskills.lang.MenuMessage)1 MessageKey (com.archyx.aureliumskills.lang.MessageKey)1 ManaAbilityManager (com.archyx.aureliumskills.mana.ManaAbilityManager)1 CommandReward (com.archyx.aureliumskills.rewards.CommandReward)1 MoneyReward (com.archyx.aureliumskills.rewards.MoneyReward)1 Reward (com.archyx.aureliumskills.rewards.Reward)1 Skill (com.archyx.aureliumskills.skills.Skill)1 Stat (com.archyx.aureliumskills.stats.Stat)1 ItemUtils (com.archyx.aureliumskills.util.item.ItemUtils)1 NumberUtil (com.archyx.aureliumskills.util.math.NumberUtil)1 RomanNumber (com.archyx.aureliumskills.util.math.RomanNumber)1 TextUtil (com.archyx.aureliumskills.util.text.TextUtil)1