Class NBTUtils

java.lang.Object
net.minestom.server.utils.NBTUtils

public final class NBTUtils
extends java.lang.Object
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static interface  NBTUtils.EnchantmentSetter  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.Object fromNBT​(org.jglrxavpok.hephaistos.nbt.NBT nbt)
    Converts a nbt object to its raw value.
    static void loadAllItems​(org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> items, Inventory destination)
    Loads all the items from the 'items' list into the given inventory
    static void loadDataIntoItem​(ItemStack item, org.jglrxavpok.hephaistos.nbt.NBTCompound nbt)  
    static void loadEnchantments​(org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> enchantments, NBTUtils.EnchantmentSetter setter)  
    static ItemStack readItemStack​(BinaryReader reader)  
    static void saveAllItems​(org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> list, Inventory inventory)  
    static void saveDataIntoNBT​(ItemStack itemStack, org.jglrxavpok.hephaistos.nbt.NBTCompound itemNBT)  
    static org.jglrxavpok.hephaistos.nbt.NBT toNBT​(java.lang.Object value, java.lang.Class type, boolean supportDataType)
    Converts an object into its NBT equivalent.
    static void writeEnchant​(org.jglrxavpok.hephaistos.nbt.NBTCompound nbt, java.lang.String listName, java.util.Map<Enchantment,​java.lang.Short> enchantmentMap)  
    static void writeItemStack​(BinaryWriter packet, ItemStack itemStack)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • loadAllItems

      public static void loadAllItems​(@NotNull org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> items, @NotNull Inventory destination)
      Loads all the items from the 'items' list into the given inventory
      Parameters:
      items - the items to save
      destination - the inventory destination
    • saveAllItems

      public static void saveAllItems​(@NotNull org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> list, @NotNull Inventory inventory)
    • writeEnchant

      public static void writeEnchant​(@NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound nbt, @NotNull java.lang.String listName, @NotNull java.util.Map<Enchantment,​java.lang.Short> enchantmentMap)
    • readItemStack

      @Nullable public static ItemStack readItemStack​(@NotNull BinaryReader reader)
    • loadDataIntoItem

      public static void loadDataIntoItem​(@NotNull ItemStack item, @NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound nbt)
    • loadEnchantments

      public static void loadEnchantments​(org.jglrxavpok.hephaistos.nbt.NBTList<org.jglrxavpok.hephaistos.nbt.NBTCompound> enchantments, NBTUtils.EnchantmentSetter setter)
    • writeItemStack

      public static void writeItemStack​(BinaryWriter packet, ItemStack itemStack)
    • saveDataIntoNBT

      public static void saveDataIntoNBT​(@NotNull ItemStack itemStack, @NotNull org.jglrxavpok.hephaistos.nbt.NBTCompound itemNBT)
    • toNBT

      @Nullable public static org.jglrxavpok.hephaistos.nbt.NBT toNBT​(@NotNull java.lang.Object value, @NotNull java.lang.Class type, boolean supportDataType)
      Converts an object into its NBT equivalent.

      If type is not a primitive type or primitive array and supportDataType is true, the data will be encoded with the appropriate DataType into a byte array.

      Parameters:
      value - the value to convert
      type - the type of the value, used to know which DataType to use if value is not a primitive type
      supportDataType - true to allow using a DataType to encode value into a byte array if not a primitive type
      Returns:
      the converted value, null if type is not a primitive type and supportDataType is false
    • fromNBT

      public static java.lang.Object fromNBT​(@NotNull org.jglrxavpok.hephaistos.nbt.NBT nbt)
      Converts a nbt object to its raw value.

      Currently support number, string, byte/int/long array.

      Parameters:
      nbt - the nbt tag to convert
      Returns:
      the value representation of a tag
      Throws:
      java.lang.UnsupportedOperationException - if the tag type is not supported