Package com.cryptomorin.xseries.unused
Class ZEnchantment
java.lang.Object
com.cryptomorin.xseries.unused.ZEnchantment
public final class ZEnchantment extends Object
Cross-version enchantment support with multiple aliases.
Uses EssentialsX enchantment list for aliases.
This class will not be updated.
Enchantment levels do not start from 0, they start from 1 EssentialsX Enchantment: https://github.com/Bukkit/Bukkit/blob/master/src/main/java/org/bukkit/enchantments/Enchantment.java Enchantment: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/enchantments/Enchantment.html Enchanting: https://minecraft.gamepedia.com/Enchanting
- Version:
- 1.0.0
- Author:
- Crypto Morin
- See Also:
Enchantment
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.collect.ImmutableMap<String,org.bukkit.enchantments.Enchantment>
ALIASENCHANTMENTS
static com.google.common.collect.ImmutableMap<String,org.bukkit.enchantments.Enchantment>
ENCHANTMENTS
-
Constructor Summary
Constructors Constructor Description ZEnchantment()
-
Method Summary
Modifier and Type Method Description static org.bukkit.inventory.ItemStack
addEnchantFromString(org.bukkit.inventory.ItemStack item, String enchantment)
Adds an unsafe enchantment to the given item from a string.static List<String>
getAllEnchantmentNames()
Includes bothgetEnchantments()
andgetEnchantmentAliases()
Should be saved in memory if you want to use it multiple times.static Optional<org.bukkit.enchantments.Enchantment>
getByName(String enchant)
Gets an enchantment from Vanilla and bukkit names.static com.google.common.collect.ImmutableList<String>
getEnchantmentAliases()
static com.google.common.collect.ImmutableList<String>
getEnchantments()
-
Field Details
-
ENCHANTMENTS
public static final com.google.common.collect.ImmutableMap<String,org.bukkit.enchantments.Enchantment> ENCHANTMENTS -
ALIASENCHANTMENTS
public static final com.google.common.collect.ImmutableMap<String,org.bukkit.enchantments.Enchantment> ALIASENCHANTMENTS
-
-
Constructor Details
-
ZEnchantment
public ZEnchantment()
-
-
Method Details
-
getByName
@Nullable public static Optional<org.bukkit.enchantments.Enchantment> getByName(@Nonnull String enchant)Gets an enchantment from Vanilla and bukkit names. There are also some aliases available.- Parameters:
enchant
- the name of the enchantment.- Returns:
- an enchantment.
- Since:
- 1.0.0
-
addEnchantFromString
@Nonnull public static org.bukkit.inventory.ItemStack addEnchantFromString(@Nonnull org.bukkit.inventory.ItemStack item, @Nonnull String enchantment)Adds an unsafe enchantment to the given item from a string.ItemStack item = ...; addEnchantFromString(item, "unbreaking, 10"); addEnchantFromString(item, "mending");
Note that if you set your item's meta
ItemStack.setItemMeta(ItemMeta)
the enchantment will be removed. You need to useItemMeta.addEnchant(Enchantment, int, boolean)
instead. You can use thegetByName(String)
method in this case.- Parameters:
item
- the item to add the enchantment to.enchantment
- the enchantment string containing the enchantment name and level (optional)- Returns:
- an enchanted
ItemStack
. - Since:
- 1.0.0
-
getEnchantments
-
getEnchantmentAliases
-
getAllEnchantmentNames
Includes bothgetEnchantments()
andgetEnchantmentAliases()
Should be saved in memory if you want to use it multiple times.- Returns:
- concatenation of the main and the aliases lists.
- Since:
- 1.0.0
-