use of com.archyx.aureliumskills.modifier.ModifierType in project AureliumSkills by Archy-X.
the class RequirementManager method load.
public void load() {
FileConfiguration config = plugin.getConfig();
this.globalRequirements = new HashSet<>();
for (ModifierType type : ModifierType.values()) {
List<String> list = config.getStringList("requirement." + type.name().toLowerCase(Locale.ENGLISH) + ".global");
for (String text : list) {
String[] splitText = text.split(" ");
Optional<XMaterial> potentialMaterial = XMaterial.matchXMaterial(splitText[0].toUpperCase());
if (potentialMaterial.isPresent()) {
XMaterial material = potentialMaterial.get();
Map<Skill, Integer> requirements = new HashMap<>();
for (int i = 1; i < splitText.length; i++) {
String requirementText = splitText[i];
try {
Skill skill = plugin.getSkillRegistry().getSkill(requirementText.split(":")[0]);
if (skill != null) {
int level = Integer.parseInt(requirementText.split(":")[1]);
requirements.put(skill, level);
}
} catch (Exception e) {
Bukkit.getLogger().warning("[AureliumSkills] Error parsing global skill " + type.name().toLowerCase(Locale.ENGLISH) + " requirement skill level pair with text " + requirementText);
}
}
GlobalRequirement globalRequirement = new GlobalRequirement(type, material, requirements);
globalRequirements.add(globalRequirement);
} else {
Bukkit.getLogger().warning("[AureliumSkills] Error parsing global skill " + type.name().toLowerCase(Locale.ENGLISH) + " requirement material with text " + splitText[0]);
}
}
}
}
use of com.archyx.aureliumskills.modifier.ModifierType in project AureliumSkills by Archy-X.
the class Requirements method convertFromLegacy.
public ItemStack convertFromLegacy(ItemStack item) {
if (isNBTDisabled())
return item;
NBTItem nbtItem = new NBTItem(item);
NBTCompound oldRequirementsCompound = nbtItem.getCompound("skillRequirements");
if (oldRequirementsCompound != null) {
for (ModifierType type : ModifierType.values()) {
NBTCompound oldTypeCompound = oldRequirementsCompound.getCompound(type.toString().toLowerCase(Locale.ENGLISH));
if (oldTypeCompound != null) {
NBTCompound compound = ItemUtils.getRequirementsTypeCompound(nbtItem, type);
for (String key : oldTypeCompound.getKeys()) {
compound.setInteger(StringUtils.capitalize(key), oldTypeCompound.getInteger(key));
}
}
}
}
nbtItem.removeKey("skillRequirements");
return nbtItem.getItem();
}
Aggregations