use of com.archyx.aureliumskills.api.event.SkillLevelUpEvent in project AureliumSkills by Archy-X.
the class Leveler method levelUpSkill.
private void levelUpSkill(PlayerData playerData, Skill skill) {
Player player = playerData.getPlayer();
Locale locale = playerData.getLocale();
double currentXp = playerData.getSkillXp(skill);
int level = playerData.getSkillLevel(skill) + 1;
playerData.setSkillXp(skill, currentXp - xpRequirements.getXpRequired(skill, level));
playerData.setSkillLevel(skill, level);
// Give custom rewards
List<Reward> rewards = plugin.getRewardManager().getRewardTable(skill).getRewards(level);
for (Reward reward : rewards) {
reward.giveReward(player, skill, level);
}
// Adds money rewards if enabled
if (plugin.isVaultEnabled()) {
if (OptionL.getBoolean(Option.SKILL_MONEY_REWARDS_ENABLED)) {
Economy economy = plugin.getEconomy();
double base = OptionL.getDouble(Option.SKILL_MONEY_REWARDS_BASE);
double multiplier = OptionL.getDouble(Option.SKILL_MONEY_REWARDS_MULTIPLIER);
economy.depositPlayer(player, base + (multiplier * level * level));
}
}
// Reload items and armor to check for newly met requirements
plugin.getModifierManager().reloadPlayer(player);
// Calls event
SkillLevelUpEvent event = new SkillLevelUpEvent(player, skill, level);
Bukkit.getPluginManager().callEvent(event);
// Sends messages
if (OptionL.getBoolean(Option.LEVELER_TITLE_ENABLED)) {
sendTitle(player, locale, skill, level);
}
if (OptionL.getBoolean(Option.LEVELER_SOUND_ENABLED)) {
playSound(player);
}
player.sendMessage(getLevelUpMessage(player, playerData, skill, level, locale, rewards));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> checkLevelUp(player, skill), OptionL.getInt(Option.LEVELER_DOUBLE_CHECK_DELAY));
}
Aggregations