Fixed SkillClass

This commit is contained in:
Auxilor 2021-04-16 16:25:15 +01:00
parent dba5d45508
commit 35f0bd3f63

View File

@ -1,18 +1,9 @@
package com.willfp.ecoskills.classes; package com.willfp.ecoskills.classes;
import com.willfp.eco.util.StringUtils;
import com.willfp.ecoskills.config.ClassConfig; import com.willfp.ecoskills.config.ClassConfig;
import com.willfp.ecoskills.enchantments.EcoEnchants;
import com.willfp.ecoskills.enchantments.util.EnchantmentUtils;
import lombok.Getter; import lombok.Getter;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.stream.Collectors;
public abstract class SkillClass { public abstract class SkillClass {
/** /**
* The name of the class. * The name of the class.
@ -37,31 +28,5 @@ public abstract class SkillClass {
public void update() { public void update() {
config.update(); config.update();
config.loadFromLang();
rarity = config.getRarity();
Validate.notNull(rarity, "Rarity specified in " + this.permissionName + " is invalid!");
conflicts = config.getEnchantments(EcoEnchants.GENERAL_LOCATION + "conflicts");
grindstoneable = config.getBool(EcoEnchants.GENERAL_LOCATION + "grindstoneable");
availableFromTable = config.getBool(EcoEnchants.OBTAINING_LOCATION + "table");
availableFromVillager = config.getBool(EcoEnchants.OBTAINING_LOCATION + "villager");
availableFromLoot = config.getBool(EcoEnchants.OBTAINING_LOCATION + "loot");
maxLevel = config.getInt(EcoEnchants.GENERAL_LOCATION + "maximum-level", 1);
name = StringUtils.translate(config.getString("name"));
description = StringUtils.translate(config.getString("description"));
disabledWorldNames.clear();
disabledWorldNames.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "disabled-in-worlds"));
disabledWorlds.clear();
List<String> worldNames = Bukkit.getWorlds().stream().map(World::getName).map(String::toLowerCase).collect(Collectors.toList());
List<String> disabledExistingWorldNames = disabledWorldNames.stream().filter(s -> worldNames.contains(s.toLowerCase())).collect(Collectors.toList());
disabledWorlds.addAll(Bukkit.getWorlds().stream().filter(world -> disabledExistingWorldNames.contains(world.getName().toLowerCase())).collect(Collectors.toList()));
targets.clear();
targetMaterials.clear();
targets.addAll(config.getTargets());
targets.forEach(enchantmentTarget -> targetMaterials.addAll(enchantmentTarget.getMaterials()));
enabled = config.getBool("enabled");
EnchantmentUtils.registerPlaceholders(this);
postUpdate();
this.register();
} }
} }