Updated to eco 6.19.0

This commit is contained in:
Auxilor 2022-01-13 12:32:41 +00:00
parent 71483fbca0
commit cf41a467da
19 changed files with 30 additions and 30 deletions

View File

@ -55,7 +55,7 @@ allprojects {
} }
dependencies { dependencies {
compileOnly 'com.willfp:eco:6.17.1' compileOnly 'com.willfp:eco:6.19.0'
implementation 'com.willfp:libreforge:3.0.0' implementation 'com.willfp:libreforge:3.0.0'
compileOnly 'org.jetbrains:annotations:19.0.0' compileOnly 'org.jetbrains:annotations:19.0.0'

View File

@ -255,7 +255,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
availableFromLoot = config.getBool(EcoEnchants.OBTAINING_LOCATION + "loot"); availableFromLoot = config.getBool(EcoEnchants.OBTAINING_LOCATION + "loot");
maxLevel = config.getInt(EcoEnchants.GENERAL_LOCATION + "maximum-level", 1); maxLevel = config.getInt(EcoEnchants.GENERAL_LOCATION + "maximum-level", 1);
displayName = config.getFormattedString("name"); displayName = config.getFormattedString("name");
description = config.getString("description", false); description = config.getString("description");
disabledWorldNames.clear(); disabledWorldNames.clear();
disabledWorldNames.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "disabled-in-worlds")); disabledWorldNames.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "disabled-in-worlds"));
disabledWorlds.clear(); disabledWorlds.clear();
@ -273,7 +273,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
flags.clear(); flags.clear();
flags.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "flags")); flags.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "flags"));
EnchantmentUtils.registerPlaceholders(this); EnchantmentUtils.registerPlaceholders(this);
for (String req : config.getStrings(EcoEnchants.GENERAL_LOCATION + "requirements.list", false)) { for (String req : config.getStrings(EcoEnchants.GENERAL_LOCATION + "requirements.list")) {
List<String> split = Arrays.asList(req.split(":")); List<String> split = Arrays.asList(req.split(":"));
if (split.size() < 2) { if (split.size() < 2) {
continue; continue;
@ -284,7 +284,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
this.requirements.put(requirement, split.subList(1, split.size())); this.requirements.put(requirement, split.subList(1, split.size()));
} }
requirementLore.clear(); requirementLore.clear();
requirementLore.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "requirements.not-met-lore", false)); requirementLore.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "requirements.not-met-lore"));
postUpdate(); postUpdate();
this.register(); this.register();

View File

@ -53,7 +53,7 @@ public class Arborist extends EcoEnchant {
List<Material> materials = new ArrayList<>(); List<Material> materials = new ArrayList<>();
for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items", false)) { for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items")) {
Material material = Material.getMaterial(materialName.toUpperCase()); Material material = Material.getMaterial(materialName.toUpperCase());
if (material != null) { if (material != null) {
materials.add(material); materials.add(material);

View File

@ -60,7 +60,7 @@ public class BlastMining extends EcoEnchant {
} }
Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(x, y, z)); Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(x, y, z));
if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks", false).contains(block1.getType().name().toLowerCase())) { if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) {
continue; continue;
} }

View File

@ -47,7 +47,7 @@ public class Drill extends EcoEnchant {
Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(simplified)); Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(simplified));
block1.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true)); block1.setMetadata("block-ignore", this.getPlugin().getMetadataValueFactory().create(true));
if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks", false).contains(block1.getType().name().toLowerCase())) { if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) {
continue; continue;
} }

View File

@ -45,7 +45,7 @@ public class Instantaneous extends EcoEnchant {
List<Material> blacklist = new ArrayList<>(); List<Material> blacklist = new ArrayList<>();
for (String s : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks", false)) { for (String s : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks")) {
blacklist.add(Material.getMaterial(s)); blacklist.add(Material.getMaterial(s));
} }

View File

@ -29,7 +29,7 @@ public class Lumberjack extends EcoEnchant {
@Override @Override
protected void postUpdate() { protected void postUpdate() {
materials = new ArrayList<>(); materials = new ArrayList<>();
for (String string : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks", false)) { for (String string : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks")) {
Material match = Material.getMaterial(string.toUpperCase()); Material match = Material.getMaterial(string.toUpperCase());
if (match != null) { if (match != null) {
materials.add(match); materials.add(match);

View File

@ -72,7 +72,7 @@ public class Spearfishing extends EcoEnchant {
} }
List<Material> potentialDrops = new ArrayList<>(); List<Material> potentialDrops = new ArrayList<>();
this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "drops", false).forEach(material -> { this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "drops").forEach(material -> {
potentialDrops.add(Material.getMaterial(material.toUpperCase())); potentialDrops.add(Material.getMaterial(material.toUpperCase()));
}); });

View File

@ -39,7 +39,7 @@ public class Transfuse extends EcoEnchant {
return; return;
} }
if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "works-on", false).contains(block.getType().toString().toLowerCase())) { if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "works-on").contains(block.getType().toString().toLowerCase())) {
return; return;
} }
@ -47,10 +47,10 @@ public class Transfuse extends EcoEnchant {
Material material; Material material;
double random = NumberUtils.randFloat(0, 1); double random = NumberUtils.randFloat(0, 1);
double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).size(); double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size();
int selectedIndex = (int) Math.floor(random / band); int selectedIndex = (int) Math.floor(random / band);
selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).size() - 1); selectedIndex = Math.min(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1);
String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).get(selectedIndex); String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").get(selectedIndex);
material = Material.getMaterial(materialName.toUpperCase()); material = Material.getMaterial(materialName.toUpperCase());
if (material == null) { if (material == null) {
material = Material.COBBLESTONE; material = Material.COBBLESTONE;

View File

@ -40,7 +40,7 @@ public class Vein extends EcoEnchant {
List<Material> materials = Collections.singletonList(block.getType()); List<Material> materials = Collections.singletonList(block.getType());
if (!this.getConfig() if (!this.getConfig()
.getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks", false) .getStrings(EcoEnchants.CONFIG_LOCATION + "whitelisted-blocks")
.contains(block.getType().toString().toLowerCase())) { .contains(block.getType().toString().toLowerCase())) {
return; return;
} }

View File

@ -48,10 +48,10 @@ public class WoodSwitcher extends EcoEnchant {
Material material; Material material;
double random = NumberUtils.randFloat(0, 1); double random = NumberUtils.randFloat(0, 1);
double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).size(); double band = 1 / (double) this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size();
int selectedIndex = (int) Math.floor(random / band); int selectedIndex = (int) Math.floor(random / band);
selectedIndex = NumberUtils.equalIfOver(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).size() - 1); selectedIndex = Math.min(selectedIndex, this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").size() - 1);
String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false).get(selectedIndex); String materialName = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks").get(selectedIndex);
material = Material.getMaterial(materialName.toUpperCase()); material = Material.getMaterial(materialName.toUpperCase());
if (material == null) { if (material == null) {

View File

@ -55,7 +55,7 @@ public class Dynamite extends Spell {
} }
Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(x, y, z)); Block block1 = block.getWorld().getBlockAt(block.getLocation().clone().add(x, y, z));
if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks", false).contains(block1.getType().name().toLowerCase())) { if (this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks").contains(block1.getType().name().toLowerCase())) {
continue; continue;
} }

View File

@ -79,7 +79,7 @@ public abstract class Artifact extends EcoEnchant {
@NotNull final Block block, @NotNull final Block block,
final int level, final int level,
@NotNull final BlockBreakEvent event) { @NotNull final BlockBreakEvent event) {
if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "on-blocks", false).contains(block.getType().name().toLowerCase())) { if (!this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "on-blocks").contains(block.getType().name().toLowerCase())) {
return; return;
} }

View File

@ -105,7 +105,7 @@ public class EnchantmentRarity {
double lootProbability = rarityYml.getDouble("rarities." + rarity + ".loot-probability"); double lootProbability = rarityYml.getDouble("rarities." + rarity + ".loot-probability");
String customColor = null; String customColor = null;
if (rarityYml.getBool("rarities." + rarity + ".custom-color.enabled")) { if (rarityYml.getBool("rarities." + rarity + ".custom-color.enabled")) {
customColor = rarityYml.getString("rarities." + rarity + ".custom-color.color", false); customColor = rarityYml.getString("rarities." + rarity + ".custom-color.color");
} }
new EnchantmentRarity(rarity, probability, minimumLevel, villagerProbability, lootProbability, customColor).register(); new EnchantmentRarity(rarity, probability, minimumLevel, villagerProbability, lootProbability, customColor).register();

View File

@ -35,7 +35,7 @@ public class EnchantmentType {
public static final EnchantmentType NORMAL = new EnchantmentType( public static final EnchantmentType NORMAL = new EnchantmentType(
"normal", "normal",
false, false,
() -> PLUGIN.getLangYml().getString("normal-color", false) () -> PLUGIN.getLangYml().getString("normal-color")
); );
/** /**
@ -46,7 +46,7 @@ public class EnchantmentType {
public static final EnchantmentType CURSE = new EnchantmentType( public static final EnchantmentType CURSE = new EnchantmentType(
"curse", "curse",
false, false,
() -> PLUGIN.getLangYml().getString("curse-color", false) () -> PLUGIN.getLangYml().getString("curse-color")
); );
/** /**
@ -57,7 +57,7 @@ public class EnchantmentType {
public static final EnchantmentType SPECIAL = new EnchantmentType( public static final EnchantmentType SPECIAL = new EnchantmentType(
"special", "special",
() -> !PLUGIN.getConfigYml().getBool("types.special.allow-multiple"), () -> !PLUGIN.getConfigYml().getBool("types.special.allow-multiple"),
() -> PLUGIN.getLangYml().getString("special-color", false) () -> PLUGIN.getLangYml().getString("special-color")
); );
/** /**
@ -68,7 +68,7 @@ public class EnchantmentType {
public static final EnchantmentType ARTIFACT = new EnchantmentType( public static final EnchantmentType ARTIFACT = new EnchantmentType(
"artifact", "artifact",
() -> !PLUGIN.getConfigYml().getBool("types.artifact.allow-multiple"), () -> !PLUGIN.getConfigYml().getBool("types.artifact.allow-multiple"),
() -> PLUGIN.getLangYml().getString("artifact-color", false), () -> PLUGIN.getLangYml().getString("artifact-color"),
Artifact.class Artifact.class
); );
@ -80,7 +80,7 @@ public class EnchantmentType {
public static final EnchantmentType SPELL = new EnchantmentType( public static final EnchantmentType SPELL = new EnchantmentType(
"spell", "spell",
true, true,
() -> PLUGIN.getLangYml().getString("spell-color", false), () -> PLUGIN.getLangYml().getString("spell-color"),
Spell.class Spell.class
); );

View File

@ -63,7 +63,7 @@ public class EnchantingListeners extends PluginDependent<EcoPlugin> implements L
@ConfigUpdater @ConfigUpdater
public static void update(@NotNull final EcoEnchantsPlugin plugin) { public static void update(@NotNull final EcoEnchantsPlugin plugin) {
SECONDARY_ENCHANTABLE.clear(); SECONDARY_ENCHANTABLE.clear();
for (String string : plugin.getTargetYml().getStrings("extra-enchantable-items", false)) { for (String string : plugin.getTargetYml().getStrings("extra-enchantable-items")) {
SECONDARY_ENCHANTABLE.add(Material.matchMaterial(string.toUpperCase())); SECONDARY_ENCHANTABLE.add(Material.matchMaterial(string.toUpperCase()));
} }
} }

View File

@ -48,7 +48,7 @@ public class Rainbow extends EcoEnchant {
List<Material> materials = new ArrayList<>(); List<Material> materials = new ArrayList<>();
for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items", false)) { for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "items")) {
Material material = Material.getMaterial(materialName.toUpperCase()); Material material = Material.getMaterial(materialName.toUpperCase());
if (material != null) { if (material != null) {
materials.add(material); materials.add(material);

View File

@ -67,7 +67,7 @@ public class SoftTouch extends EcoEnchant {
name = name.replace("[", "").replace("]", ""); name = name.replace("[", "").replace("]", "");
meta.setDisplayName(name); meta.setDisplayName(name);
List<String> lore = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "lore", false); List<String> lore = this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "lore");
lore.replaceAll(s -> s.replace("%type%", entityName)); lore.replaceAll(s -> s.replace("%type%", entityName));
meta.setLore(lore); meta.setLore(lore);

View File

@ -56,7 +56,7 @@ public class Xray extends Spell {
List<Material> materials = new ArrayList<>(); List<Material> materials = new ArrayList<>();
for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks", false)) { for (String materialName : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blocks")) {
Material material = Material.getMaterial(materialName.toUpperCase()); Material material = Material.getMaterial(materialName.toUpperCase());
if (material != null) { if (material != null) {
materials.add(material); materials.add(material);