Class ItemTagStream

java.lang.Object
com.saicone.rtag.stream.TStream<ItemStack>
com.saicone.rtag.item.ItemTagStream

public class ItemTagStream extends com.saicone.rtag.stream.TStream<ItemStack>
ItemTagStream class to write/read ItemStack into/from bytes.
  • Field Details

    • INSTANCE

      public static final ItemTagStream INSTANCE
      ItemTagStream public instance adapted for current server version.
  • Constructor Details

    • ItemTagStream

      public ItemTagStream()
      Constructs a simple ItemTagStream instance.
    • ItemTagStream

      public ItemTagStream(@NotNull @NotNull List<ItemMirror> mirror)
      Constructs an ItemTagStream instance with specified parameters.
      Parameters:
      mirror - a list containing item mirrors to apply.
    • ItemTagStream

      public ItemTagStream(@NotNull @NotNull List<ItemMirror> mirror, @NotNull @NotNull com.saicone.rtag.util.MC targetVersion)
      Constructs an ItemTagStream instance with specified parameters.
      Parameters:
      mirror - a list containing item mirrors to apply.
      targetVersion - the target version to convert items.
    • ItemTagStream

      @Deprecated(since="1.5.14", forRemoval=true) public ItemTagStream(@NotNull @NotNull List<ItemMirror> mirror, float version, @NotNull @NotNull String versionKey)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructs an ItemTagStream with specified ItemMirror list and additional parameters.
      Parameters:
      mirror - Mirror list.
      version - Server version.
      versionKey - Version key identifier from compound.
  • Method Details

    • valueOf

      @NotNull public static @NotNull ItemTagStream valueOf(@NotNull @NotNull com.saicone.rtag.util.MC min, @NotNull @NotNull com.saicone.rtag.util.MC target)
    • getMirror

      @NotNull public @NotNull List<ItemMirror> getMirror()
      Get current ItemMirror list.
      Returns:
      a list of item mirror.
    • getTargetVersion

      @NotNull public @NotNull com.saicone.rtag.util.MC getTargetVersion()
      The target version to convert items.
      Returns:
      a version object.
    • extract

      public Object extract(ItemStack object)
      Overrides:
      extract in class com.saicone.rtag.stream.TStream<ItemStack>
    • build

      public ItemStack build(Object compound)
      Overrides:
      build in class com.saicone.rtag.stream.TStream<ItemStack>
    • toReadableMap

      @NotNull public @NotNull Map<String,Object> toReadableMap(@NotNull @NotNull ItemStack item)
      Convert item to readable map, making display name and lore components as colored strings.
      Parameters:
      item - Item to convert.
      Returns:
      A readable map that represent the provided item.
    • fromReadableMap

      @NotNull public @NotNull ItemStack fromReadableMap(@NotNull @NotNull Map<String,Object> map)
      Get item by read provided Map of objects and also convert display name and lore to component if is required.
      Parameters:
      map - Map that represent the object.
      Returns:
      An item representation using readable Map as compound.
    • onSave

      public void onSave(@Nullable @Nullable Object compound)
      Executed method when CompoundTag is extracted from item.
      Parameters:
      compound - CompoundTag with item information.
    • onLoad

      public void onLoad(@Nullable @Nullable Object compound)
      Executed method when CompoundTag used tu build an item.
      Parameters:
      compound - CompoundTag with item information.
    • onLoad

      public void onLoad(@NotNull @NotNull Object compound, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Executed method when CompoundTag used tu build an item.
      Parameters:
      compound - CompoundTag with item information.
      from - Version specified in compound.
      to - Version to convert.
    • listToBase64

      public String listToBase64(List<ItemStack> items)
      Overrides:
      listToBase64 in class com.saicone.rtag.stream.TStream<ItemStack>
    • ofVersion

      @NotNull @Deprecated(since="1.5.14", forRemoval=true) public static @NotNull ItemTagStream ofVersion(float minVersion, float currentVersion)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create an item tag stream for provided version range.
      Parameters:
      minVersion - The minimum version to support.
      currentVersion - The current server version.
      Returns:
      A newly generated item tag stream.
    • ofVersion

      @NotNull @Deprecated(since="1.5.14", forRemoval=true) public static @NotNull ItemTagStream ofVersion(float minVersion, float currentVersion, @Nullable @Nullable String versionKey)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create an item tag stream for provided version range.
      Parameters:
      minVersion - The minimum version to support.
      currentVersion - The current server version.
      versionKey - Version key identifier from compound.
      Returns:
      A newly generated item tag stream.
    • getVersion

      @Deprecated(since="1.5.14", forRemoval=true) public float getVersion()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get current server version for this instance.
      Returns:
      Server version.
    • getVersion

      @Nullable @Deprecated(since="1.5.14", forRemoval=true) public @Nullable Float getVersion(Object compound)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get current version number from item compound.
      Parameters:
      compound - CompoundTag that represent an item.
      Returns:
      A valid version number or null.
    • getVersionKey

      @NotNull @Deprecated(since="1.5.14", forRemoval=true) public @NotNull String getVersionKey()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get current version key identifier.
      Returns:
      Version key identifier.
    • onLoad

      @Deprecated(since="1.5.14", forRemoval=true) public void onLoad(Object compound, float from, float to)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Executed method when CompoundTag used tu build an item.
      Parameters:
      compound - CompoundTag with item information.
      from - Version specified in compound.
      to - Version to convert.
    • versionMatches

      @Deprecated(since="1.5.14", forRemoval=true) protected boolean versionMatches(float from, float to)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Check if the provided pair of versions matches.
      Parameters:
      from - Version specified in compound.
      to - Version to convert.
      Returns:
      true if matches.