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 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

  • 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 use ItemMeta.addEnchant(Enchantment, int, boolean) instead. You can use the getByName(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

      @Nonnull public static com.google.common.collect.ImmutableList<String> getEnchantments()
    • getEnchantmentAliases

      @Nonnull public static com.google.common.collect.ImmutableList<String> getEnchantmentAliases()
    • getAllEnchantmentNames

      @Nonnull public static List<String> getAllEnchantmentNames()
      Includes both getEnchantments() and getEnchantmentAliases()
      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