Class NBT_Persistent

java.lang.Object
me.deecaad.core.compatibility.nbt.NBT_Persistent
All Implemented Interfaces:
NBTCompatibility

public abstract class NBT_Persistent extends Object implements NBTCompatibility
Due to class loading issues, this logic (that was originally implemented in NBTCompatibility) is now implemented here. This way, on 1.12.2, PersistentDataType is not loaded.
  • Field Summary

    Fields inherited from interface me.deecaad.core.compatibility.nbt.NBTCompatibility

    DO_NOT_MODIFY_ME, DO_NOT_MODIFY_ME_STRING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    getArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, int[] def)
    Returns the int[] value of a NBT tag with the given name key.
    double
    getDouble(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, double def)
    Returns the Double value of a NBT tag with the given name key.
    int
    getInt(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, int def)
    Returns the Integer value of a NBT tag with the given name key.
    getString(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, String def)
    Returns the String value of a NBT tag with the given name key.
    getStringArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, String[] def)
    Returns the String[] value of a NBT tag with the given name key.
    boolean
    hasArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key)
    Returns true if the given bukkitItem's NBT compound has the given key, and it is an int[] value.
    boolean
    hasDouble(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key)
    Returns true if the given bukkitItem's NBT compound has the given key, and it is a Double value.
    boolean
    hasInt(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key)
    Returns true if the given bukkitItem's NBT compound has the given key, and it is an Integer value.
    boolean
    hasString(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key)
    Returns true if the given bukkitItem's NBT compound has the given key, and it is a String value.
    boolean
    hasStringArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key)
    Returns true if the given bukkitItem's NBT compound has the given key, and it is a String[] value.
    void
    remove(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key)
    Removes the given NBT tag from the item.
    void
    setArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, int[] value)
    Sets the int[] value of a NBT tag with the given name key.
    void
    setDouble(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, double value)
    Sets the Double value of a NBT tag with the given name key.
    void
    setInt(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, int value)
    Sets the Integer value of a NBT tag with the given name key.
    void
    setString(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, String value)
    Sets the String value of a NBT tag with the given name key.
    void
    setStringArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, String[] value)
    Sets the Double value of a NBT tag with the given name key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface me.deecaad.core.compatibility.nbt.NBTCompatibility

    getArray, getDouble, getInt, getKey, getNBTDebug, getString, getStringArray
  • Constructor Details

    • NBT_Persistent

      public NBT_Persistent()
  • Method Details

    • hasString

      public boolean hasString(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key)
      Description copied from interface: NBTCompatibility
      Returns true if the given bukkitItem's NBT compound has the given key, and it is a String value. Otherwise, this method will return null.
      Specified by:
      hasString in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to check existence of.
      Returns:
      true if the NBT compound uses the tag.
    • getString

      public String getString(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, String def)
      Description copied from interface: NBTCompatibility
      Returns the String value of a NBT tag with the given name key. The value is pulled from an NBT compound contained in the given item bukkitItem. If the tag isn't used in the item's compound, then this method will return def.
      Specified by:
      getString in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to pull some value from.
      def - The default value to return if the key is not present.
      Returns:
      The value of the tag, or null.
    • setString

      public void setString(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, String value)
      Description copied from interface: NBTCompatibility
      Sets the String value of a NBT tag with the given name key. The value is put in the NBT compound stored in the given item bukkitItem.

      The stored value can be seen using NBTCompatibility.getString(ItemStack, String, String).

      Specified by:
      setString in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to store the value at.
      value - The value that will be stored.
    • hasInt

      public boolean hasInt(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key)
      Description copied from interface: NBTCompatibility
      Returns true if the given bukkitItem's NBT compound has the given key, and it is an Integer value. Otherwise, this method will return null.
      Specified by:
      hasInt in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to check existence of.
      Returns:
      true if the NBT compound uses the tag.
    • getInt

      public int getInt(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, int def)
      Description copied from interface: NBTCompatibility
      Returns the Integer value of a NBT tag with the given name key. The value is pulled from an NBT compound contained in the given item bukkitItem. If the tag isn't used in the item's compound, then this method will return def.
      Specified by:
      getInt in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to pull some value from.
      def - The default value to return if the key is not present.
      Returns:
      The value of the tag, or 0.
    • setInt

      public void setInt(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, int value)
      Description copied from interface: NBTCompatibility
      Sets the Integer value of a NBT tag with the given name key. The value is put in the NBT compound stored in the given item bukkitItem.

      The stored value can be seen using NBTCompatibility.getInt(ItemStack, String, String).

      Specified by:
      setInt in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to store the value at.
      value - The value that will be stored.
    • hasDouble

      public boolean hasDouble(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key)
      Description copied from interface: NBTCompatibility
      Returns true if the given bukkitItem's NBT compound has the given key, and it is a Double value. Otherwise, this method will return null.
      Specified by:
      hasDouble in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to check existence of.
      Returns:
      true if the NBT compound uses the tag.
    • getDouble

      public double getDouble(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, double def)
      Description copied from interface: NBTCompatibility
      Returns the Double value of a NBT tag with the given name key. The value is pulled from an NBT compound contained in the given item bukkitItem. If the tag isn't used in the item's compound, then this method will return def.
      Specified by:
      getDouble in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to pull some value from.
      def - The default value to return if the key is not present.
      Returns:
      The value of the tag, or 0.
    • setDouble

      public void setDouble(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, double value)
      Description copied from interface: NBTCompatibility
      Sets the Double value of a NBT tag with the given name key. The value is put in a compound according to the given plugin, inside of the bukkitItem NBT compound.

      The stored value can be seen using NBTCompatibility.getDouble(ItemStack, String, String).

      Specified by:
      setDouble in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to store the value at.
      value - The value that will be stored.
    • hasArray

      public boolean hasArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key)
      Description copied from interface: NBTCompatibility
      Returns true if the given bukkitItem's NBT compound has the given key, and it is an int[] value. Otherwise, this method will return null.
      Specified by:
      hasArray in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to check existence of.
      Returns:
      true if the NBT compound uses the tag.
    • getArray

      public int[] getArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, int[] def)
      Description copied from interface: NBTCompatibility
      Returns the int[] value of a NBT tag with the given name key. The value is pulled from an NBT compound contained in the given item bukkitItem. If the tag isn't used in the item's compound, then this method will return def.
      Specified by:
      getArray in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to pull some value from.
      def - The default value to return if the key is not present.
      Returns:
      The value of the tag, or def.
    • setArray

      public void setArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, int[] value)
      Description copied from interface: NBTCompatibility
      Sets the int[] value of a NBT tag with the given name key. The value is put in a compound according to the given plugin, inside of the bukkitItem NBT compound.

      The stored value can be seen using NBTCompatibility.getArray(ItemStack, String, String).

      Specified by:
      setArray in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to store the value at.
      value - The value that will be stored.
    • hasStringArray

      public boolean hasStringArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key)
      Description copied from interface: NBTCompatibility
      Returns true if the given bukkitItem's NBT compound has the given key, and it is a String[] value. Otherwise, this method will return null.
      Specified by:
      hasStringArray in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to check existence of.
      Returns:
      true if the NBT compound uses the tag.
    • getStringArray

      public String[] getStringArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, String[] def)
      Description copied from interface: NBTCompatibility
      Returns the String[] value of a NBT tag with the given name key. The value is pulled from an NBT compound contained in the given item bukkitItem. If the tag isn't used in the item's compound, then this method will return def.
      Specified by:
      getStringArray in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to pull some value from.
      def - The default value to return if the key is not present.
      Returns:
      The value of the tag, or def.
    • setStringArray

      public void setStringArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, String[] value)
      Description copied from interface: NBTCompatibility
      Sets the Double value of a NBT tag with the given name key. The value is put in a compound according to the given plugin, inside of the bukkitItem NBT compound.

      The stored value can be seen using NBTCompatibility.getStringArray(ItemStack, String, String).

      Specified by:
      setStringArray in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to store the value at.
      value - The value that will be stored.
    • remove

      public void remove(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key)
      Description copied from interface: NBTCompatibility
      Removes the given NBT tag from the item. To check to see if there was a key to delete, use NBTCompatibility.hasString(ItemStack, String, String) (or one of the hasX methods).
      Specified by:
      remove in interface NBTCompatibility
      Parameters:
      bukkitItem - The non-null item that has an NBT tag compound.
      plugin - The non-null owner of the tag, should be your plugin.
      key - The non-null name of the tag to remove.