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