mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Updated to eco 4.3.1 configs
This commit is contained in:
parent
0781246ec4
commit
a27a8fa1d2
@ -46,7 +46,7 @@ public class EnchantmentConfig extends ExtendableConfig {
|
||||
*/
|
||||
public Set<Enchantment> getEnchantments(@NotNull final String path) {
|
||||
Set<Enchantment> enchantments = new HashSet<>();
|
||||
List<String> enchantmentKeys = this.getConfig().getStringList(path);
|
||||
List<String> enchantmentKeys = this.getStrings(path);
|
||||
enchantmentKeys.forEach((key -> enchantments.add(Enchantment.getByKey(NamespacedKey.minecraft(key)))));
|
||||
return enchantments;
|
||||
}
|
||||
@ -67,7 +67,7 @@ public class EnchantmentConfig extends ExtendableConfig {
|
||||
* @return The targets.
|
||||
*/
|
||||
public Set<EnchantmentTarget> getTargets() {
|
||||
List<String> targetNames = this.getConfig().getStringList(EcoEnchants.GENERAL_LOCATION + "targets");
|
||||
List<String> targetNames = this.getStrings(EcoEnchants.GENERAL_LOCATION + "targets");
|
||||
if (targetNames.isEmpty()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
@ -88,14 +88,14 @@ public class EnchantmentConfig extends ExtendableConfig {
|
||||
* Load config values from lang.yml.
|
||||
*/
|
||||
public void loadFromLang() {
|
||||
if (!this.getPlugin().getLangYml().getConfig().contains("enchantments." + this.getName())) {
|
||||
if (!this.getPlugin().getLangYml().has("enchantments." + this.getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.getConfig().set("name", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".name"));
|
||||
this.getConfig().set("description", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".description"));
|
||||
this.config.set("name", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".name"));
|
||||
this.config.set("description", this.getPlugin().getLangYml().getString("enchantments." + this.getName() + ".description"));
|
||||
try {
|
||||
this.getConfig().save(this.getConfigFile());
|
||||
this.config.save(this.getConfigFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.willfp.ecoenchants.config.configs;
|
||||
import com.willfp.eco.util.config.BaseConfig;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
public class Rarity extends BaseConfig {
|
||||
/**
|
||||
@ -18,7 +18,7 @@ public class Rarity extends BaseConfig {
|
||||
*
|
||||
* @return Set of all rarity names.
|
||||
*/
|
||||
public Set<String> getRarities() {
|
||||
return this.getConfig().getConfigurationSection("rarities").getKeys(false);
|
||||
public List<String> getRarities() {
|
||||
return this.getSubsection("rarities").getKeys(false);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Target extends BaseConfig {
|
||||
@ -21,8 +22,8 @@ public class Target extends BaseConfig {
|
||||
*
|
||||
* @return Set of all names.
|
||||
*/
|
||||
public Set<String> getTargets() {
|
||||
return this.getConfig().getConfigurationSection("targets").getKeys(false);
|
||||
public List<String> getTargets() {
|
||||
return this.getSubsection("targets").getKeys(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,7 +34,7 @@ public class Target extends BaseConfig {
|
||||
*/
|
||||
public Set<Material> getTargetMaterials(@NotNull final String target) {
|
||||
Set<Material> materials = new HashSet<>();
|
||||
this.getConfig().getStringList("targets." + target).forEach(materialName -> {
|
||||
this.getStrings("targets." + target).forEach(materialName -> {
|
||||
materials.add(Material.getMaterial(materialName.toUpperCase()));
|
||||
});
|
||||
|
||||
|
@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -151,7 +152,7 @@ public class EnchantmentRarity {
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void update() {
|
||||
Set<String> raritiesNames = EcoEnchantsConfigs.RARITY.getRarities();
|
||||
List<String> raritiesNames = EcoEnchantsConfigs.RARITY.getRarities();
|
||||
raritiesNames.forEach(rarity -> {
|
||||
double probability = EcoEnchantsConfigs.RARITY.getDouble("rarities." + rarity + ".table-probability");
|
||||
int minimumLevel = EcoEnchantsConfigs.RARITY.getInt("rarities." + rarity + ".minimum-level");
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -72,7 +73,7 @@ public class EnchantmentTarget {
|
||||
*/
|
||||
@ConfigUpdater
|
||||
public static void update() {
|
||||
Set<String> targetNames = EcoEnchantsConfigs.TARGET.getTargets();
|
||||
List<String> targetNames = EcoEnchantsConfigs.TARGET.getTargets();
|
||||
ALL.materials.clear();
|
||||
targetNames.forEach(name -> {
|
||||
Set<Material> materials = EcoEnchantsConfigs.TARGET.getTargetMaterials(name);
|
||||
|
Loading…
Reference in New Issue
Block a user