Search in sources :

Example 51 with Skill

use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.

the class Leveler method updateStats.

public void updateStats(Player player) {
    PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
    if (playerData == null)
        return;
    for (Stat stat : plugin.getStatRegistry().getStats()) {
        playerData.setStatLevel(stat, 0);
    }
    for (Skill skill : plugin.getSkillRegistry().getSkills()) {
        plugin.getRewardManager().getRewardTable(skill).applyStats(playerData, playerData.getSkillLevel(skill));
    }
    // Reloads modifiers
    for (String key : playerData.getStatModifiers().keySet()) {
        StatModifier modifier = playerData.getStatModifiers().get(key);
        playerData.addStatLevel(modifier.getStat(), modifier.getValue());
    }
    statLeveler.reloadStat(player, Stats.HEALTH);
    statLeveler.reloadStat(player, Stats.WISDOM);
}
Also used : StatModifier(com.archyx.aureliumskills.modifier.StatModifier) Skill(com.archyx.aureliumskills.skills.Skill) Stat(com.archyx.aureliumskills.stats.Stat) PlayerData(com.archyx.aureliumskills.data.PlayerData)

Example 52 with Skill

use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.

the class Multipliers method getMultipliers.

public List<Multiplier> getMultipliers(ModifierType type, ItemStack item) {
    if (!OptionL.getBoolean(Option.MODIFIER_MULTIPLIER_ENABLED) || isNBTDisabled()) {
        // Return empty list if disabled
        return new ArrayList<>();
    }
    NBTItem nbtItem = new NBTItem(item);
    List<Multiplier> multipliers = new ArrayList<>();
    NBTCompound compound = ItemUtils.getMultipliersTypeCompound(nbtItem, type);
    for (String key : compound.getKeys()) {
        double value = compound.getDouble(key);
        // Null if Global
        Skill skill = plugin.getSkillRegistry().getSkill(key);
        String skillName = getNBTName(skill);
        if (type == ModifierType.ITEM) {
            multipliers.add(new Multiplier("AureliumSkills.Multipliers.Item." + skillName, skill, value));
        } else if (type == ModifierType.ARMOR) {
            String slot = "Helmet";
            String mat = item.getType().toString();
            if (mat.contains("CHESTPLATE")) {
                slot = "Chestplate";
            } else if (mat.contains("LEGGINGS")) {
                slot = "Leggings";
            } else if (mat.contains("BOOTS")) {
                slot = "Boots";
            }
            multipliers.add(new Multiplier("AureliumSkills.Multipliers.Armor." + slot + "." + skillName, skill, value));
        }
    }
    return multipliers;
}
Also used : Skill(com.archyx.aureliumskills.skills.Skill) ArrayList(java.util.ArrayList) NBTCompound(de.tr7zw.changeme.nbtapi.NBTCompound) NBTItem(de.tr7zw.changeme.nbtapi.NBTItem)

Example 53 with Skill

use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.

the class RewardManager method loadRewards.

public void loadRewards() {
    this.rewardTables.clear();
    File rewardsDirectory = new File(plugin.getDataFolder() + "/rewards");
    // Load each file
    int patternsLoaded = 0;
    int levelsLoaded = 0;
    for (Skill skill : plugin.getSkillRegistry().getSkills()) {
        File rewardsFile = new File(rewardsDirectory + "/" + skill.toString().toLowerCase(Locale.ROOT) + ".yml");
        if (!rewardsFile.exists()) {
            plugin.saveResource("rewards/" + skill.toString().toLowerCase(Locale.ROOT) + ".yml", false);
        }
        FileConfiguration rewardsConfig = YamlConfiguration.loadConfiguration(rewardsFile);
        RewardTable rewardTable = new RewardTable(plugin);
        // Load patterns
        patternsLoaded += loadPatterns(rewardTable, rewardsConfig, rewardsFile, OptionL.getMaxLevel(skill));
        // Load levels section
        levelsLoaded += loadLevels(rewardTable, rewardsConfig, rewardsFile);
        // Register reward table
        this.rewardTables.put(skill, rewardTable);
    }
    // Load global rewards
    File globalFile = new File(plugin.getDataFolder() + "/rewards/global.yml");
    if (!globalFile.exists()) {
        plugin.saveResource("rewards/global.yml", false);
    }
    FileConfiguration globalConfig = YamlConfiguration.loadConfiguration(globalFile);
    RewardTable globalTable = new RewardTable(plugin);
    patternsLoaded += loadPatterns(globalTable, globalConfig, globalFile, plugin.getOptionLoader().getHighestMaxLevel());
    levelsLoaded += loadLevels(globalTable, globalConfig, globalFile);
    // Apply global rewards table to each skill reward table
    for (Map.Entry<Integer, List<Reward>> entry : globalTable.getRewardsMap().entrySet()) {
        int level = entry.getKey();
        List<Reward> rewards = entry.getValue();
        for (Skill skill : plugin.getSkillRegistry().getSkills()) {
            RewardTable rewardTable = this.rewardTables.get(skill);
            if (rewardTable != null) {
                for (Reward reward : rewards) {
                    rewardTable.addReward(reward, level);
                }
            }
        }
    }
    plugin.getLogger().info("Loaded " + patternsLoaded + " pattern rewards and " + levelsLoaded + " level rewards");
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Skill(com.archyx.aureliumskills.skills.Skill) File(java.io.File)

Example 54 with Skill

use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.

the class ArcheryLeveler method onEntityDeath.

@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDeath(EntityDeathEvent event) {
    if (OptionL.isEnabled(Skills.ARCHERY)) {
        if (OptionL.getBoolean(Option.ARCHERY_DAMAGE_BASED))
            return;
        LivingEntity e = event.getEntity();
        if (e.getKiller() != null) {
            if (e.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
                EntityDamageByEntityEvent ee = (EntityDamageByEntityEvent) e.getLastDamageCause();
                if (ee.getDamager() instanceof Projectile) {
                    EntityType type = e.getType();
                    Player p = e.getKiller();
                    Skill skill = Skills.ARCHERY;
                    if (ee.getDamager() instanceof ThrownPotion) {
                        if (OptionL.getBoolean(Option.ALCHEMY_GIVE_XP_ON_POTION_COMBAT)) {
                            // Reward alchemy if potion used
                            skill = Skills.ALCHEMY;
                        } else {
                            return;
                        }
                    }
                    if (blockXpGainLocation(e.getLocation(), p))
                        return;
                    if (blockXpGainPlayer(p))
                        return;
                    if (e.equals(p))
                        return;
                    double spawnerMultiplier = OptionL.getDouble(Option.ARCHERY_SPAWNER_MULTIPLIER);
                    try {
                        if (e.hasMetadata("aureliumskills_spawner_mob")) {
                            plugin.getLeveler().addXp(p, skill, spawnerMultiplier * getXp(p, ArcherySource.valueOf(type.toString())));
                        } else {
                            plugin.getLeveler().addXp(p, skill, getXp(p, ArcherySource.valueOf(type.toString())));
                        }
                    } catch (IllegalArgumentException exception) {
                        if (type.toString().equals("PIG_ZOMBIE")) {
                            if (e.hasMetadata("aureliumskills_spawner_mob")) {
                                plugin.getLeveler().addXp(p, skill, spawnerMultiplier * getXp(p, ArcherySource.ZOMBIFIED_PIGLIN));
                            } else {
                                plugin.getLeveler().addXp(p, skill, getXp(p, ArcherySource.ZOMBIFIED_PIGLIN));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Skill(com.archyx.aureliumskills.skills.Skill) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Skill (com.archyx.aureliumskills.skills.Skill)54 PlayerData (com.archyx.aureliumskills.data.PlayerData)15 Locale (java.util.Locale)15 Player (org.bukkit.entity.Player)13 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)12 File (java.io.File)11 IOException (java.io.IOException)9 ItemStack (org.bukkit.inventory.ItemStack)8 EventHandler (org.bukkit.event.EventHandler)7 Stat (com.archyx.aureliumskills.stats.Stat)6 InvalidCommandArgument (co.aikar.commands.InvalidCommandArgument)5 SkillValue (com.archyx.aureliumskills.leaderboard.SkillValue)5 StatModifier (com.archyx.aureliumskills.modifier.StatModifier)5 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)5 AbilityData (com.archyx.aureliumskills.data.AbilityData)4 KeyIntPair (com.archyx.aureliumskills.util.misc.KeyIntPair)4 Map (java.util.Map)4 AureliumSkills (com.archyx.aureliumskills.AureliumSkills)3 OptionL (com.archyx.aureliumskills.configuration.OptionL)3 Lang (com.archyx.aureliumskills.lang.Lang)3