Class IEnchantMirror

java.lang.Object
com.saicone.rtag.item.mirror.IEnchantMirror
All Implemented Interfaces:
ItemMirror

public class IEnchantMirror extends Object implements ItemMirror
IEnchantMirror class to convert item enchants across versions.
  • Field Details

    • fromString

      public static final Map<Object,Object> fromString
      Map to get TagBase enchantment ID from String.
    • fromShort

      public static final Map<Object,Object> fromShort
      Map to get TagBase enchantment namespaced key from Short ID.
  • Constructor Details

    • IEnchantMirror

      @Deprecated(since="1.5.14", forRemoval=true) public IEnchantMirror(float version)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructs an IEnchantMirror with specified server versions to create keys automatically.
      Parameters:
      version - The server version to create keys for.
    • IEnchantMirror

      public IEnchantMirror(@NotNull @NotNull com.saicone.rtag.util.MC version)
      Constructs an IEnchantMirror with specified server versions to create keys automatically.
      Parameters:
      version - the server version to create keys for.
    • IEnchantMirror

      public IEnchantMirror(@NotNull @NotNull Map<Object,Object> map, @NotNull @NotNull String bookKey, @NotNull @NotNull String fromKey, @NotNull @NotNull String toKey)
      Constructs an IEnchantMirror with specified parameters.
      Parameters:
      map - Enchantments map with IDs and names.
      bookKey - Key to handle with enchanted book.
      fromKey - Key to get current item enchants.
      toKey - New key to set converted enchants.
  • Method Details

    • getMap

      public Map<Object,Object> getMap()
      Get current enchantments map.
      Returns:
      A map with enchantments names and IDs.
    • getMaximumVersion

      @NotNull public @NotNull com.saicone.rtag.util.MC getMaximumVersion()
      Description copied from interface: ItemMirror
      Get the maximum compatible version, exclusive.
      Specified by:
      getMaximumVersion in interface ItemMirror
      Returns:
      a version.
    • upgrade

      public void upgrade(@NotNull @NotNull Object compound, @NotNull @NotNull String id, @NotNull @NotNull Object components, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Description copied from interface: ItemMirror
      Upgrade current item tag compound from lower version.
      Specified by:
      upgrade in interface ItemMirror
      Parameters:
      compound - the tag compound that represents item data.
      id - the item material id.
      components - the item components, on older versions this may be the item tag.
      from - the initial version of item data.
      to - the version to upgrade item data.
    • downgrade

      public void downgrade(@NotNull @NotNull Object compound, @NotNull @NotNull String id, @NotNull @NotNull Object components, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Description copied from interface: ItemMirror
      Downgrade current item tag compound from upper version.
      Specified by:
      downgrade in interface ItemMirror
      Parameters:
      compound - the tag compound that represents item data.
      id - the item material id.
      components - the item components, on older versions this may be the item tag.
      from - the initial version of item data.
      to - the version to downgrade item data.
    • processEnchants

      @Internal public void processEnchants(@NotNull @NotNull Object tag, boolean book)
      Process current item enchants inside tag.
      Parameters:
      tag - ItemStack tag.
      book - True if the tag is from enchanted book.