Package 

Class NbtCompound

  • All Implemented Interfaces:
    kotlin.collections.Map , kotlin.collections.MutableMap

    
    public final class NbtCompound
    extends NbtTag implements Map<String, NbtTag>
                        

    A tag which contains a MutableMap structure associating Strings to NbtTags.

    It's the main heart of NBT files and usually contains complex structures.

    The returned tags by this class will be linked, so modifications to it will also affect the compound value.

    All get functions which are not prefixed with Nullable and get will throw a ClassCastException if the tag is mapped to a different class then the method used. For example if a given compound have an example=NbtInt(2) and you try to read it using NbtCompound.getShort, an exception will be thrown.

    All get functions which are not prefixed with Nullable and get will throw NoSuchElementException if no value is mapped to the given name. This will change in the future.

    All get list functions which returns lists of specific types will throw IllegalStateException if the list content does not match the requested type.

    • Method Detail

      • getStringValue

         String getStringValue()

        Returns a string representation of the tag's value.

        The NbtList and the array types will have an output similar to a normal List and NbtCompound to a normal Map.

        The class names of the NbtList's and NbtCompound's children will expose.

        The returned string is compatible with string constructors of the same type.

        Be aware that this may be a slow operation on big lists, arrays or compounds.

      • set

         final Unit set(String key, NbtTag value)

        Directly maps a NbtTag to a key. The value must not be NbtEnd. The given tag will be linked, so modifications to it will also affect the compound value.

      • set

         final Unit set(String key, ByteArray value)

        Maps a NbtByteArray with the given value. The array instance will be linked so any modification will also change the tag value.

      • set

         final Unit set(String key, IntArray value)

        Maps a NbtByteArray with the given value. The array instance will be linked so any modification will also change the tag value.

      • set

         final Unit set(String key, LongArray value)

        Maps a NbtByteArray with the given value. The array instance will be linked so any modification will also change the tag value.

      • require

         final NbtTag require(String key)

        Returns the value corresponding to the given key, or throw an exception if such a key is not present in the compound.

      • getByteArray

         final ByteArray getByteArray(String key)

        Returns the unwrapped byte array value. The array will be linked and any modification will also change wrapper and the mapped value.

      • getIntArray

         final IntArray getIntArray(String key)

        Returns the unwrapped int array value. The array will be linked and any modification will also change wrapper and the mapped value.

      • getLongArray

         final LongArray getLongArray(String key)

        Returns the unwrapped long array value. The array will be linked and any modification will also change wrapper and the mapped value.

      • getList

         final NbtList<?> getList(String key)

        Returns the NbtList mapped to that key. The tag will be linked and any modification will also change the mapped value.

      • getIntList

         final NbtList<NbtInt> getIntList(String key)

        Returns the NbtList of integers mapped to that key. The tag will be linked and any modification will also change the mapped value.

      • getListOfList

         final NbtList<NbtList<?>> getListOfList(String key)

        Returns the NbtList of lists mapped to that key. The tag and it's values will be linked and any modification will also change the mapped value.

      • getNullableByte

         final Byte getNullableByte(String key)

        Returns the unwrapped byte value or null if no value is mapped, or it is mapped to another type tag.

      • getNullableShort

         final Short getNullableShort(String key)

        Returns the unwrapped short value or null if no value is mapped, or it is mapped to another type tag.

      • getNullableInt

         final Integer getNullableInt(String key)

        Returns the unwrapped int value or null if no value is mapped, or it is mapped to another type tag.

      • getNullableLong

         final Long getNullableLong(String key)

        Returns the unwrapped long value or null if no value is mapped, or it is mapped to another type tag.

      • getNullableFloat

         final Float getNullableFloat(String key)

        Returns the unwrapped float value or null if no value is mapped, or it is mapped to another type tag.

      • getNullableDouble

         final Double getNullableDouble(String key)

        Returns the unwrapped double value or null if no value is mapped, or it is mapped to another type tag.

      • getNullableByteArray

         final ByteArray getNullableByteArray(String key)

        Returns the unwrapped byte array value. The array will be linked and any modification will also change wrapper and the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableString

         final String getNullableString(String key)

        Returns the unwrapped string value or null if no value is mapped, or it is mapped to another type tag.

      • getNullableIntArray

         final IntArray getNullableIntArray(String key)

        Returns the unwrapped int array value. The array will be linked and any modification will also change wrapper and the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableLongArray

         final LongArray getNullableLongArray(String key)

        Returns the unwrapped long array value. The array will be linked and any modification will also change wrapper and the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableCompound

         final NbtCompound getNullableCompound(String key)

        Returns the NbtCompound mapped to that key. The tag will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableList

         final NbtList<?> getNullableList(String key)

        Returns the NbtList mapped to that key. The tag will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableByteList

         final NbtList<NbtByte> getNullableByteList(String key)

        Returns the NbtList of bytes mapped to that key. The tag will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableShortList

         final NbtList<NbtShort> getNullableShortList(String key)

        Returns the NbtList of shorts mapped to that key. The tag will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableIntList

         final NbtList<NbtInt> getNullableIntList(String key)

        Returns the NbtList of integers mapped to that key. The tag will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableLongList

         final NbtList<NbtLong> getNullableLongList(String key)

        Returns the NbtList of longs mapped to that key. The tag will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableFloatList

         final NbtList<NbtFloat> getNullableFloatList(String key)

        Returns the NbtList of floats mapped to that key. The tag will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableDoubleList

         final NbtList<NbtDouble> getNullableDoubleList(String key)

        Returns the NbtList of doubles mapped to that key. The tag will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableByteArrayList

         final NbtList<NbtByteArray> getNullableByteArrayList(String key)

        Returns the NbtList of byte arrays mapped to that key. The tag and it's value will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableStringList

         final NbtList<NbtString> getNullableStringList(String key)

        Returns the NbtList of strings mapped to that key. The tag will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableIntArrayList

         final NbtList<NbtIntArray> getNullableIntArrayList(String key)

        Returns the NbtList of int arrays mapped to that key. The tag and it's value will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableLongArrayList

         final NbtList<NbtLongArray> getNullableLongArrayList(String key)

        Returns the NbtList of long arrays mapped to that key. The tag and it's values will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableCompoundList

         final NbtList<NbtCompound> getNullableCompoundList(String key)

        Returns the NbtList of compounds mapped to that key. The tag and it's values will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • getNullableListOfList

         final NbtList<NbtList<?>> getNullableListOfList(String key)

        Returns the NbtList of lists mapped to that key. The tag and it's values will be linked and any modification will also change the mapped value.

        Will return null if no value is mapped, or it is mapped to another type tag.

      • copyFrom

         final Unit copyFrom(NbtCompound other, String tagKey, NbtTag default)

        Checks if the other compound have a given tag, if it has been placed it in this compound.

        The tag will be linked, so any change in the tag will also affect both compounds.

        Parameters:
        other - The compound that will be checked
        tagKey - The name of the tag that will be mapped
        default - If the other compound doesn't have the tag then this parameter will be used.
      • copyTo

         final Unit copyTo(NbtCompound other, String tagKey, NbtTag default)

        Checks if the compound have a given tag, if it has been placed it in the other compound.

        The tag will be linked, so any change in the tag will also affect both compounds.

        Parameters:
        other - The compound that will be modified
        tagKey - The name of the tag that will be mapped
        default - If the compound doesn't have the tag then this parameter will be used.
      • deepCopy

         NbtCompound deepCopy()

        Returns a new NbtCompound with all nested values copied deeply.