Search in sources :

Example 1 with MoneyReward

use of com.archyx.aureliumskills.rewards.MoneyReward in project AureliumSkills by Archy-X.

the class ProgressLevelItem method getRewardsLore.

public String getRewardsLore(Skill skill, int level, Player player, Locale locale) {
    ImmutableList<Reward> rewards = plugin.getRewardManager().getRewardTable(skill).getRewards(level);
    StringBuilder message = new StringBuilder();
    double totalMoney = 0;
    for (Reward reward : rewards) {
        message.append(reward.getMenuMessage(player, locale, skill, level));
        if (reward instanceof MoneyReward) {
            totalMoney += ((MoneyReward) reward).getAmount();
        }
    }
    // Legacy money rewards
    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 * level * level);
        }
    }
    if (totalMoney > 0) {
        message.append(TextUtil.replace(Lang.getMessage(MenuMessage.MONEY_REWARD, locale), "{amount}", NumberUtil.format2(totalMoney)));
    }
    return TextUtil.replace(Lang.getMessage(MenuMessage.REWARDS, locale), "{rewards}", message.toString());
}
Also used : MoneyReward(com.archyx.aureliumskills.rewards.MoneyReward) Reward(com.archyx.aureliumskills.rewards.Reward) MoneyReward(com.archyx.aureliumskills.rewards.MoneyReward)

Example 2 with MoneyReward

use of com.archyx.aureliumskills.rewards.MoneyReward 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

MoneyReward (com.archyx.aureliumskills.rewards.MoneyReward)2 Reward (com.archyx.aureliumskills.rewards.Reward)2 Ability (com.archyx.aureliumskills.ability.Ability)1 MAbility (com.archyx.aureliumskills.mana.MAbility)1 CommandReward (com.archyx.aureliumskills.rewards.CommandReward)1 DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1