Interface NBTCompatibility
- All Known Implementing Classes:
NBT_Persistent
public interface NBTCompatibility
This interface outlines a version dependant api that return values based on different
ItemStack and tag input. There should be an implementing class for each minecraft
protocol version.
NBT stands for Named Binary Tag.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault int[]getArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) Returns the int[] value of a NBT tag with the given namekey.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 namekey.default doublegetDouble(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) Returns theDoublevalue of a NBT tag with the given namekey.doublegetDouble(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, double def) Returns theDoublevalue of a NBT tag with the given namekey.default intgetInt(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) Returns theIntegervalue of a NBT tag with the given namekey.intgetInt(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, int def) Returns theIntegervalue of a NBT tag with the given namekey.default org.bukkit.NamespacedKey@NotNull StringgetNBTDebug(@NotNull org.bukkit.inventory.ItemStack bukkitStack) Returns theObject.toString()value of an item's NBT compound, useful for debugging.default StringgetString(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) Returns theStringvalue of a NBT tag with the given namekey.getString(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, String def) Returns theStringvalue of a NBT tag with the given namekey.default String[]getStringArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) Returns theString[] value of a NBT tag with the given namekey.String[]getStringArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, String[] def) Returns theString[] value of a NBT tag with the given namekey.booleanhasArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) Returnstrueif the givenbukkitItem's NBT compound has the givenkey, and it is an int[] value.booleanhasDouble(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) booleanhasInt(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) booleanhasString(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) booleanhasStringArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) voidremove(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key) Removes the given NBT tag from the item.voidsetArray(@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 namekey.voidsetDouble(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, double value) Sets theDoublevalue of a NBT tag with the given namekey.voidsetInt(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, int value) Sets theIntegervalue of a NBT tag with the given namekey.voidsetString(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, String value) Sets theStringvalue of a NBT tag with the given namekey.voidsetStringArray(@NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull String plugin, @NotNull String key, String[] value) Sets theDoublevalue of a NBT tag with the given namekey.
-
Field Details
-
DO_NOT_MODIFY_ME
static final int[] DO_NOT_MODIFY_ME -
DO_NOT_MODIFY_ME_STRING
-
-
Method Details
-
hasString
boolean hasString(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returnstrueif the givenbukkitItem's NBT compound has the givenkey, and it is aStringvalue. Otherwise, this method will returnnull.- 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:
trueif the NBT compound uses the tag.
-
getString
default String getString(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returns theStringvalue of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will returnnull.- 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.- Returns:
- The value of the tag, or
null.
-
getString
String getString(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, String def) Returns theStringvalue of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will returndef.- 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
void setString(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, String value) Sets theStringvalue of a NBT tag with the given namekey. The value is put in the NBT compound stored in the given itembukkitItem.The stored value can be seen using
getString(ItemStack, String, String).- 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
boolean hasInt(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returnstrueif the givenbukkitItem's NBT compound has the givenkey, and it is anIntegervalue. Otherwise, this method will returnnull.- 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:
trueif the NBT compound uses the tag.
-
getInt
default int getInt(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returns theIntegervalue of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will return0.- 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.- Returns:
- The value of the tag, or
0.
-
getInt
int getInt(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, int def) Returns theIntegervalue of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will returndef.- 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
void setInt(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, int value) Sets theIntegervalue of a NBT tag with the given namekey. The value is put in the NBT compound stored in the given itembukkitItem.The stored value can be seen using
getInt(ItemStack, String, String).- 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
boolean hasDouble(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returnstrueif the givenbukkitItem's NBT compound has the givenkey, and it is aDoublevalue. Otherwise, this method will returnnull.- 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:
trueif the NBT compound uses the tag.
-
getDouble
default double getDouble(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returns theDoublevalue of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will return0.0.- 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.- Returns:
- The value of the tag, or
0.
-
getDouble
double getDouble(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, double def) Returns theDoublevalue of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will returndef.- 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
void setDouble(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, double value) Sets theDoublevalue of a NBT tag with the given namekey. The value is put in a compound according to the givenplugin, inside of thebukkitItemNBT compound.The stored value can be seen using
getDouble(ItemStack, String, String).- 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
boolean hasArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returnstrueif the givenbukkitItem's NBT compound has the givenkey, and it is an int[] value. Otherwise, this method will returnnull.- 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:
trueif the NBT compound uses the tag.
-
getArray
default int[] getArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returns the int[] value of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will return0.0.- 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.- Returns:
- The value of the tag, or an empty array.
-
getArray
int[] getArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, int[] def) Returns the int[] value of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will returndef.- 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
void setArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, int[] value) Sets the int[] value of a NBT tag with the given namekey. The value is put in a compound according to the givenplugin, inside of thebukkitItemNBT compound.The stored value can be seen using
getArray(ItemStack, String, String).- 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
boolean hasStringArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returnstrueif the givenbukkitItem's NBT compound has the givenkey, and it is aString[] value. Otherwise, this method will returnnull.- 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:
trueif the NBT compound uses the tag.
-
getStringArray
default String[] getStringArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Returns theString[] value of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will return0.0.- 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.- Returns:
- The value of the tag, or an empty array.
-
getStringArray
String[] getStringArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, String[] def) Returns theString[] value of a NBT tag with the given namekey. The value is pulled from an NBT compound contained in the given itembukkitItem. If the tag isn't used in the item's compound, then this method will returndef.- 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
void setStringArray(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key, String[] value) Sets theDoublevalue of a NBT tag with the given namekey. The value is put in a compound according to the givenplugin, inside of thebukkitItemNBT compound.The stored value can be seen using
getStringArray(ItemStack, String, String).- 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
void remove(@NotNull @NotNull org.bukkit.inventory.ItemStack bukkitItem, @NotNull @NotNull String plugin, @NotNull @NotNull String key) Removes the given NBT tag from the item. To check to see if there was a key to delete, usehasString(ItemStack, String, String)(or one of thehasXmethods).- 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.
-
getKey
-
getNBTDebug
Returns theObject.toString()value of an item's NBT compound, useful for debugging.- Parameters:
bukkitStack- The non-null bukkit item to check the nbt tags of.- Returns:
- The non-null string value of the nbt compound.
-