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