mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-25 20:17:38 +01:00
Code cleanup
This commit is contained in:
parent
d46a15881a
commit
a4741283dd
@ -21,7 +21,7 @@ public class EnchantmentRarity {
|
|||||||
private static final Set<EnchantmentRarity> REGISTERED = new HashSet<>();
|
private static final Set<EnchantmentRarity> REGISTERED = new HashSet<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
update();
|
update(EcoEnchantsPlugin.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,8 +94,8 @@ public class EnchantmentRarity {
|
|||||||
* Update all rarities.
|
* Update all rarities.
|
||||||
*/
|
*/
|
||||||
@ConfigUpdater
|
@ConfigUpdater
|
||||||
public static void update() {
|
public static void update(@NotNull final EcoEnchantsPlugin plugin) {
|
||||||
RarityYml rarityYml = EcoEnchantsPlugin.getInstance().getRarityYml();
|
RarityYml rarityYml = plugin.getRarityYml();
|
||||||
List<String> raritiesNames = rarityYml.getRarities();
|
List<String> raritiesNames = rarityYml.getRarities();
|
||||||
raritiesNames.forEach(rarity -> {
|
raritiesNames.forEach(rarity -> {
|
||||||
double probability = rarityYml.getDouble("rarities." + rarity + ".table-probability");
|
double probability = rarityYml.getDouble("rarities." + rarity + ".table-probability");
|
||||||
|
@ -25,7 +25,7 @@ public class EnchantmentTarget {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
REGISTERED.add(ALL);
|
REGISTERED.add(ALL);
|
||||||
update();
|
update(EcoEnchantsPlugin.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,11 +67,11 @@ public class EnchantmentTarget {
|
|||||||
* Update all targets.
|
* Update all targets.
|
||||||
*/
|
*/
|
||||||
@ConfigUpdater
|
@ConfigUpdater
|
||||||
public static void update() {
|
public static void update(@NotNull final EcoEnchantsPlugin plugin) {
|
||||||
List<String> targetNames = EcoEnchantsPlugin.getInstance().getTargetYml().getTargets();
|
List<String> targetNames = plugin.getTargetYml().getTargets();
|
||||||
ALL.materials.clear();
|
ALL.materials.clear();
|
||||||
targetNames.forEach(name -> {
|
targetNames.forEach(name -> {
|
||||||
Set<Material> materials = EcoEnchantsPlugin.getInstance().getTargetYml().getTargetMaterials(name);
|
Set<Material> materials = plugin.getTargetYml().getTargetMaterials(name);
|
||||||
new EnchantmentTarget(name, materials).register();
|
new EnchantmentTarget(name, materials).register();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package com.willfp.ecoenchants.enchantments.support.vanilla;
|
package com.willfp.ecoenchants.enchantments.support.vanilla;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||||
import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy;
|
import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy;
|
||||||
import com.willfp.ecoenchants.util.ProxyUtils;
|
import com.willfp.ecoenchants.util.ProxyUtils;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -15,11 +17,6 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class VanillaEnchantments {
|
public class VanillaEnchantments {
|
||||||
/**
|
|
||||||
* Instance of EcoEnchants.
|
|
||||||
*/
|
|
||||||
private static final EcoEnchantsPlugin PLUGIN = EcoEnchantsPlugin.getInstance();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vanilla Enchantment Metadata Map.
|
* Vanilla Enchantment Metadata Map.
|
||||||
*/
|
*/
|
||||||
@ -37,14 +34,14 @@ public class VanillaEnchantments {
|
|||||||
/**
|
/**
|
||||||
* Update the map.
|
* Update the map.
|
||||||
*/
|
*/
|
||||||
public static void update() {
|
public static void update(@NotNull final EcoEnchantsPlugin plugin) {
|
||||||
Map<Enchantment, VanillaEnchantmentMetadata> map = new HashMap<>();
|
Map<Enchantment, VanillaEnchantmentMetadata> map = new HashMap<>();
|
||||||
|
|
||||||
List<Enchantment> enchantments = Arrays.stream(Enchantment.values())
|
List<Enchantment> enchantments = Arrays.stream(Enchantment.values())
|
||||||
.filter(enchantment -> enchantment.getClass().getName().contains("CraftEnchantment"))
|
.filter(enchantment -> enchantment.getClass().getName().contains("CraftEnchantment"))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
Map<Enchantment, Integer> maxLevels = PLUGIN.getVanillaEnchantsYml().getStrings("max-levels").stream()
|
Map<Enchantment, Integer> maxLevels = plugin.getVanillaEnchantsYml().getStrings("max-levels").stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
s -> Enchantment.getByKey(NamespacedKey.minecraft(s.split(":")[0].toLowerCase())),
|
s -> Enchantment.getByKey(NamespacedKey.minecraft(s.split(":")[0].toLowerCase())),
|
||||||
s1 -> Integer.parseInt(s1.split(":")[1])
|
s1 -> Integer.parseInt(s1.split(":")[1])
|
||||||
@ -59,7 +56,7 @@ public class VanillaEnchantments {
|
|||||||
MAP.clear();
|
MAP.clear();
|
||||||
MAP.putAll(map);
|
MAP.putAll(map);
|
||||||
|
|
||||||
if (PLUGIN.getVanillaEnchantsYml().getBool("enabled")) {
|
if (plugin.getVanillaEnchantsYml().getBool("enabled")) {
|
||||||
ProxyUtils.getProxy(EcoCraftEnchantmentManagerProxy.class).registerNewCraftEnchantments();
|
ProxyUtils.getProxy(EcoCraftEnchantmentManagerProxy.class).registerNewCraftEnchantments();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ public class WatcherTriggers extends PluginDependent implements Listener {
|
|||||||
* Update if allowed on npc.
|
* Update if allowed on npc.
|
||||||
*/
|
*/
|
||||||
@ConfigUpdater
|
@ConfigUpdater
|
||||||
public static void update() {
|
public static void update(@NotNull final EcoEnchantsPlugin plugin) {
|
||||||
allowOnNPC = EcoEnchantsPlugin.getInstance().getConfig().getBoolean("allow-on-npc");
|
allowOnNPC = plugin.getConfig().getBoolean("allow-on-npc");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user