Added VanillaEcoEnchantWrapper

This commit is contained in:
Auxilor
2021-04-27 10:35:55 +01:00
parent 51f046bd97
commit 77053e71f8
2 changed files with 30 additions and 0 deletions

View File

@@ -236,10 +236,12 @@ import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Dynamite;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Missile;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Quake;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Vitalize;
import com.willfp.ecoenchants.enchantments.itemtypes.VanillaEcoEnchantWrapper;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import lombok.experimental.UtilityClass;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.jetbrains.annotations.NotNull;
@@ -602,4 +604,14 @@ public class EcoEnchants {
BY_KEY.remove(enchant.getKey());
BY_NAME.inverse().remove(enchant);
}
static {
for (Enchantment value : Enchantment.values()) {
if (value instanceof EcoEnchant || value instanceof EnchantmentWrapper) {
continue;
}
new VanillaEcoEnchantWrapper(value);
}
}
}

View File

@@ -0,0 +1,18 @@
package com.willfp.ecoenchants.enchantments.itemtypes;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("deprecation")
public class VanillaEcoEnchantWrapper extends EcoEnchant {
/**
* Create a new Vanilla EcoEnchant Wrapper.
*
* @param enchantment The enchantment to wrap.
*/
public VanillaEcoEnchantWrapper(@NotNull final Enchantment enchantment) {
super(enchantment.getKey().getKey(), enchantment.isCursed() ? EnchantmentType.CURSE : EnchantmentType.NORMAL);
}
}