NBT API icon

NBT API -----

Add custom NBT tags or modify tags of Items/Entities/Tiles without NMS!




Sorry for the delay of posting this version as an official release, real-life happened. As always, dev builds with 1.21.4 support have been available since spigot 1.21.4 was released.

## What's Changed
* Add 1.21.4 support
* Add new experimental NBTJsonUtil#itemStackToJson method to use for 1.20.3+ Chat Hover Components
* Update wiki by @SoSeDiK in https://github.com/tr7zw/Item-NBT-API/pull/308
* Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.10.1 to 3.11.1 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/306

**Full Changelog**: https://github.com/tr7zw/Item-NBT-API/compare/2.14.0...2.14.1
----------, Dec 16, 2024

## What's Changed
* Add 1.21.3 support (and 1.21.2, but you shouldn't be using this version)
* Hide NBTFile/NBTContainer fully behind NBT (methods are now deprecated, pointing to the equivalent NBT replacement)
* Add missing addCompound(ReadableNBT comp) to ReadWriteNBTCompoundList
* Fix edge-case in writing out Bukkit items without data
* Try to auto-detect pre 1.20.3 item nbt also via the "Count" tag for updating
* Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.8.0 to 3.10.0 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/297
* Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.10.0 to 3.10.1 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/300


**Full Changelog**: https://github.com/tr7zw/Item-NBT-API/compare/2.13.2...2.14.0
----------, Nov 2, 2024

## What's Changed
* Fix Paper 1.21
* Fix resolveCompound in ReadWriteNBT not returning ReadWriteNBT
* Add a missing ``@Nullable`` flag to resolveCompound
* Removed old incorrect mappings on newer versions
* General code cleanup
* Fix datafixer now knowing the 1.21 version id
* Update wiki by @SoSeDiK in https://github.com/tr7zw/Item-NBT-API/pull/282

If you have questions about how to migrate your code away from NBTItem or how to support 1.20.5+ with the new ItemStack logic, check out the updated wiki! SoSeDiK did an amazing job updating the wiki, including many updated examples. Also, feel free to PR your plugin to the Plugin list on the wiki.

**Full Changelog**: https://github.com/tr7zw/Item-NBT-API/compare/2.13.0...2.13.1
----------, Aug 10, 2024

What's Changed
  • Fix Paper 1.21
  • Fix resolveCompound in ReadWriteNBT not returning ReadWriteNBT
  • Add a missing @Nullable flag to resolveCompound
  • Removed old incorrect mappings on newer versions
  • General code cleanup
  • Fix datafixer now knowing the 1.21 version id
  • Update wiki by @SoSeDiK in https://github.com/tr7zw/Item-NBT-API/pull/282

If you have questions about how to migrate your code away from NBTItem or how to support 1.20.5+ with the new ItemStack logic, check out the updated wiki! SoSeDiK did an amazing job updating the wiki, including many updated examples. Also, feel free to PR your plugin to the Plugin list on the wiki.

Full Changelog: https://github.com/tr7zw/Item-NBT-API/compare/2.13.0...2.13.1
----------, Jun 20, 2024

What's Changed
  • Update to 1.21
  • Deprecated lots of old methods/constructors. Please migrate to the NBT class for faster and abstracted alternatives
  • Added new NBT.modifyComponents API for 1.20.5+ to modify vanilla components
  • Removed nbt-injector(you really shouldn't be using this) and nbt-data-api(never finished). This removed a lot of bloat from the jar
  • Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.3 to 3.7.0 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/279
  • Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.3 to 3.6.0 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/278

Full Changelog: https://github.com/tr7zw/Item-NBT-API/compare/2.12.4...2.13.0
----------, Jun 13, 2024

## What's Changed
* Add 1.20.5 & 1.20.6 support
* Add Datafixer support to upgrade item NBT to newer versions
* Auto upgrade old ItemStacks when using ``NBT.itemStackFromNBT`` and the related methods (it will assume the NBT is 1.20.4 data, otherwise upgrade the NBT before yourself with the Datafixer)
* Fix BlockEntity bug on Mojang mapped servers
* Bump org.apache.maven.plugins:maven-source-plugin from 3.3.0 to 3.3.1 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/273
* Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.2 to 3.5.3 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/277

## Note
Due to Mojang changes to how ItemStacks work at runtime, vanilla NBT won't be visible on loaded ItemStacks in 1.20.5+ anymore. So modifying vanilla data will not work anymore in the same way as for 1.8-1.20.4, and all plugins need to be updated to be aware of that. If in doubt, feel free to ask on Discord.

**Full Changelog**: https://github.com/tr7zw/Item-NBT-API/compare/2.12.3...2.12.4
----------, Apr 30, 2024

## What's Changed
* Add support for un-remapped Paper 1.20+

## Other changes
* Bump org.apache.maven.plugins:maven-compiler-plugin from 3.11.0 to 3.12.0 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/261
* Bump org.apache.maven.plugins:maven-compiler-plugin from 3.12.0 to 3.12.1 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/263
* Update LICENSE copyright to 2024 by @SmartGecko44 in https://github.com/tr7zw/Item-NBT-API/pull/264
* Bump org.codehaus.mojo:license-maven-plugin from 2.3.0 to 2.4.0 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/265
* Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.1 to 3.5.2 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/267
* Bump org.apache.maven.plugins:maven-compiler-plugin from 3.12.1 to 3.13.0 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/270

## New Contributors
* @SmartGecko44 made their first contribution in https://github.com/tr7zw/Item-NBT-API/pull/264

**Full Changelog**: https://github.com/tr7zw/Item-NBT-API/compare/2.12.2...2.12.3
----------, Mar 24, 2024

Sorry for the delay due to irl stuff.

## What's Changed
* Add 1.20.4 support
* Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.0 to 3.6.2 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/256
* Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.2 to 3.6.3 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/258


**Full Changelog**: https://github.com/tr7zw/Item-NBT-API/compare/2.12.1...2.12.2
----------, Dec 10, 2023

## What's Changed
* Fix 1.19R3 using the wrong mapping, causing a test to fail
* Fix internal version ID of 1.20R2
* Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.0 to 3.5.1 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/250
* Bump org.codehaus.mojo:license-maven-plugin from 2.2.0 to 2.3.0 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/253


**Full Changelog**: https://github.com/tr7zw/Item-NBT-API/compare/2.12.0...2.12.1
----------, Nov 4, 2023

2.12.0

Hello everyone, this is the by far biggest NBTAPI update so far. This release contains 100 commits of the total 580 total commits(17% of all commits of the past 7 years?!?), so strap in for the changes.

(Also small reminder that supporting the dev behind this project would be really nice, especially when you use this API to make paid Plugins )

Late changes between 2.12.0-RC1 and 2.12.0:
  • Add 1.20.2 support
  • Fix getKeys on empty ItemStacks
  • Fix modifyMeta on empty ItemStacks
  • Add support for ProxiedLists
  • Add support for using indices like [123] or [-1] in resolve methods
  • Hard prevent Jitpack. If you are using Jitpack for whatever reason, check the wiki to use the correct repo!

Major Changes
  • Add support for Mojang-Mapped servers(Paper-Mojmap/Paper dev mode)
  • Add support for Folia
  • HEAVY performance improvements for NBT.get and NBT.modify (see below)
  • Preview: Interface proxies to access NBT without writing code(see below)
  • Entity/BlockEntity modifications are now atomic and faster to prevent pitfalls
  • Entity/BlockEntity read-only is now a lot faster by only getting the tag once
  • Added resolveOrNull/resolveOrDefault/resolveCompound/resolveOrCreateCompound. They take . separated strings to keys like tag.othertag.key (see below for examples)

Noteworthy Changes
  • Updated bStats from version 1? to 3.0.2
  • Reduced logging for Gson
  • Added long[] support with setLongArray/getLongArray (1.16+)
  • Include NBTAPI version in errors
  • Removed the "functional-annotations" dependency shading users might have noticed
  • Fixed NBTFile.saveTo always saving the root instead of the passed tag
  • Added @Nullable in some key places
  • When the tag is empty at the end of NBT.modify, the tag gets removed from the item instead of saving an empty {} tag
  • Prevented some misuse of the NBT.get/NBT.modify methods
  • New set(String key, T value, NBTHandler<T> handler) method to set your custom data with the provided handler
  • New get(String key, NBTHandler<T> handler) method to get your custom data with the provided handler

Other Changes/Documentation
  • Bump license-maven-plugin from 2.0.1 to 2.1.0 by [mention]dependabot[/mention] in Pull Request #229
  • Bump maven-shade-plugin from 3.4.1 to 3.5.0 by [mention]dependabot[/mention] in Pull Request #232
  • Bump license-maven-plugin from 2.1.0 to 2.2.0 by [mention]dependabot[/mention] in Pull Request #235
  • Read-only optimization by [mention]tr7zw[/mention] in Pull Request #236
  • Update "set skull skin" documentation by [mention]BlackBaroness[/mention] in Pull Request #237
  • Fix minor English mistakes in documentation by [mention]BlackBaroness[/mention] in Pull Request #238
  • add honorable plugin list mentions by [mention]U5B[/mention] in Pull Request #242
  • Fix Folia detection and NBT#modify for tile entities by [mention]SoSeDiK[/mention] in Pull Request #243

Performance
This release has a lot of performance optimizations under the hood, mainly for the NBT.get and NBT.modify methods for ItemStacks/Entities/BlockEntities. I highly encourage everyone to start updating their NBTItem/ NBTEntity/ NBTTileEntity code to use these new methods.
All benchmarks are done on Paper-171 on my local PC with 2.11.3 vs 2.12.0-RC1. The numbers are how often the test case was able to run in one second(the JVM did have some warmup time before on these methods). But since it's just one run there is probably a +-5% margin of error on these values, they are just there to get a rough idea.

Itemstacks
Link to the code that runs. The legacy tests use new NBTItem, while the others use the NBT class. Both tests get/set the same data, just changing between the old and new syntax!

NMS-Backed Itemstacks:
  • LegacyGet: 880.620 -> 909.369 = ~3% faster
  • NBT.get: 884.326 -> 4.214.210 = ~376% faster
  • LegacySet: 762.453 -> 804.732 = ~5% faster
  • NBT.modify: 298.238 -> 1.781.667 = ~497% faster

Bukkit-only Itemstacks:
  • LegacyGet: 215.992 -> 202.413 = ~6% slower
  • NBT.get: 223.998 -> 649.626 = ~190% faster
  • LegacySet: 229.485 -> 239.910 = ~4% faster
  • NBT.modify: 166.048 -> 567.107 = 241% faster

Basically, switch to the new NBT.get/ NBT.modify method and get at least 200% more performance compared to before.

Persistent Data Container

To get a better idea on the performance of using the NBTAPI to store data on items vs Spigots Persistent Data Container API I checked and compared these too. Again, Paper-171 on 2.12.0-RC1. On NMS-Backed Itemstacks normal PDC is about the same speed as NBT.get. Only when caching the NamespacedKey in a final class field PDC pulls ahead. Writing data, especially on Bukkit-only items is a lot slower, but still easily 500.000+ times per second, so doubt that it's much of an issue(especially for gaining a way more flexible API and pre-1.14 support).

Resolve methods

To simplify working with deeply nested NBT, resolve methods now allow directly getting or working with these tags.
Compounds are separated by .. In case you need a . inside a key, it can be escaped with a \.
Examples:
Code (Text):

// sets foo/bar/baz/test to 42
nbt.resolveOrCreateCompound("foo.bar.baz").setInteger("test", 42);
// gets the value we just set or 0
nbt.resolveOrDefault("foo.bar.baz.test", 0);
// gets the value we just set or null
nbt.resolveOrNull("foo.bar.baz.test", int.class);
// example of a key with a . in it. Sets the key foo/some.key/baz/other
nbt.resolveOrCreateCompound("foo.some\\.key.baz").setInteger("other", 123)
// get a tag or null when it's not there
nbt.resolveCompound("some.nested.key");
 
Interface Proxies

This is a preview feature contained in this release, and the API might change depending on feedback/development. It allows defining an Interface with normal methods/default methods, and the NBTAPI wraps the NBT with an automatically generated implementation of this Interface.

Methods starting with has/ get/ set will be interpreted as their respective calls:
public boolean hasKills(); runs return nbt.hasTag("kills");
public void setKills(int amount); runs nbt.setInteger("kills", amount);
public int getKills(); runs return nbt.getInteger("kills");
Default methods like
Code (Text):

        public default void addKill() {
            setKills(getKills() + 1);
        }
 
inside the interface are supported. Also having a getter return another Interface that also extends NBTProxy is supported.
To support other datatypes like ItemStacks, the init method can be overwritten with a default method, using the registerHandler method to add handlers. For example:
Code (Text):

        @Override
        default void init() {
            registerHandler(ItemStack.class, NBTHandlers.ITEM_STACK);
        }
 
To now use your interface, just call NBT.modify or NBT.readNbt like this:
Code (Text):

NBT.modify(item, TestInterface.class, ti -> {
ti.addKill();
//or any other method from your interface
});
// This instance can only run read-only methods. Calling any setter will cause an exception
TestInterface yourInterface = NBT.readNbt(item, TestInterface.class);
yourInterface .getKills();
 
For the complete example check the built-in startup test or the WIP NBT-ItemMeta proxy. Also feel free to ask on Discord.

New Contributors

Full Changelog: https://github.com/tr7zw/Item-NBT-API/compare/2.11.3...2.12.0-RC1
----------, Sep 21, 2023

What's Changed
* Add 1.20 support
* Try printing the shaders plugin name in incompatibility messages
* Print warning when shading the plugin instead of the api/setting the shaded target to "de.tr7zw.nbtapi" (this is reserved for the official plugin)
* Disable version check for shaded versions by default(turn back on using MinecraftVersion.enableUpdateCheck())
* Add support for boolean in getOrDefault/getOrNull by @SoSeDiK in https://github.com/tr7zw/Item-NBT-API/pull/222
* Allow checking nbt type alongside the key by @SoSeDiK in https://github.com/tr7zw/Item-NBT-API/pull/223
* Bump license-maven-plugin from 2.0.0 to 2.0.1 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/221
* Fix a small typo in nbt-injector by @tom-devv in https://github.com/tr7zw/Item-NBT-API/pull/224
* Bump maven-source-plugin from 3.2.1 to 3.3.0 by @dependabot in https://github.com/tr7zw/Item-NBT-API/pull/227

A heads-up

More features like Mojang mapped jars/Folia support and a cleaner way to access data using interfaces are on the way. You should consider joining the discord to join the discussion.

New Contributors
* @tom-devv made their first contribution in https://github.com/tr7zw/Item-NBT-API/pull/224

Full Changelog: https://github.com/tr7zw/Item-NBT-API/compare/2.11.2...2.11.3
----------, Jun 7, 2023

* Add 1.19.4 as officially supported(2.11.1 will work fine on 1.19.4, but show a warning that it doesn't know about this version)
* Fixed the return type of getOrCreateCompound/getCompound in ReadWriteNBT to be ReadWriteNBT too
----------, Mar 16, 2023

What's Changed
* Fix StackOverflowError when merging ReadableNBT by @Kevin-OVI in https://github.com/tr7zw/Item-NBT-API/pull/204

New Contributors
* @Kevin-OVI made their first contribution in https://github.com/tr7zw/Item-NBT-API/pull/204

Full Changelog: https://github.com/tr7zw/Item-NBT-API/compare/2.11.0...2.11.1
----------, Dec 14, 2022

New major NBTAPI release, adding 1.19.3 support and a new way to interact with the API.

Changes:
- 1.19.3 support
- Added interfaces to most nbt logic, including read-only versions
- Added a new utility class NBT, which provides clean lambda access to read and write NBT. https://github.com/tr7zw/Item-NBT-API/wiki/Using-the-NBT-API has updated examples on how to use this class.
- Utility readFrom/saveTo methods to NBTFile
- hasTag as alternative for hasKey, returning boolean instead of Boolean
- Added getOrDefault method
- Added getOrNull method
- Deprecated setObject/getObject, please do the serialization yourself using your preferred lib/settings
- getUUID/setUUID now will handle pre-1.16 and post-1.16 formats correctly on their own
- getItemStack will now return null if the tag is not found
- getKeys is now a copy of the Set, and no longer linked to NMS internal objects
- Added setItemStackArray/getItemStackArray methods
- Added modifyMeta methods to ItemStacks. Do not modify the NBT while inside the modifyMeta scope
- The wiki is now inside the Github repository, so anyone can make pull requests to add examples, clarifications etc.
- NBTItem now will correctly reject ItemStacks of size 0
- Updated a lot of Javadoc
- The full API Javadoc is now available under https://tr7zw.github.io/Item-NBT-API/v2-api/
- Pulling the NBTAPI plugin via Maven/Gradle will now also correctly contain the API Javadoc(only had the plugin Javadoc before)
- Fixed small NPE error during error reporting(ironic)
- NBTCompoundList now extend NBTList<ReadWriteNBT> instead of NBTList<NBTListCompound>. This is a compile-time breaking change, and code needs to be updated accordingly. Already published plugins should not be affected by this.
----------, Dec 11, 2022

Added:

- 1.19 support
- 1.7.10 Crucible support(use the latest build). Thanks, EverNife
----------, Jun 12, 2022

Since the releases are not hosted on SpigotMC itself I kinda forgot to post it as a resource update here. NBTAPI 2.9.2 adds 1.18.2 support, so 1.18.2-1.7.10 is supported. The releases are available via maven too.
Changes(since 2.8.0):
  • Added 1.18/1.18.1/1.18.2 support
  • Fixes files not getting closed in case of an exception during saving of NBTFiles(thanks honkling)
  • Adds more info to exceptions
  • Adds config value to do a startup without self-check or log messages(because for some reason people like server logs not saying anything?!?)
  • Tweaked some error messages to be more descriptive
  • Removed usage of System.out
----------, Mar 12, 2022

  • Add 1.17 support
  • Fix some licenses overwriting each other issues
  • Fix availability spelling
  • Update internal dependencies
----------, Jun 13, 2021

First of all, I wish everyone a happy new year! Let this release be a gift for the new year: Thanks to a change made by md_5 spigot 1.16.4+ now supports NBTChunks and NBTBlocks! This means adding custom nbt to random blocks is now possible. Noteworthy: The NBTBlock just saves nbt to the block location, it won't clear this data on block break or interact at all with piston moves. You need to implement that yourself if you want this behavior!
(Also for now curse forge will only show 2.7.0. That version is the same as 2.7.1 that will show up later there, 2.7.0 just had a pom issue that prevents developers from loading it via Maven/Gradle. So for devs: use 2.7.1 as dependency, for server owners: Use 2.7.0 or 2.7.1 as soon as it shows up, they are the same :).

Now to the actuall changelog:
Adds new features enabled by 1.16.4 and adds more usability features/fixes:
  • Add NBTChunk for 1.16.4+
  • Add NBTBlock helper for 1.16.4+
  • Add NBTPersistentDataContainer(Mostly for api internal use) for 1.14+
  • (Hopefully) created a better implementation for equals checks
  • Add getListType method
  • Add getOrCreateCompound for more clarity
----------, Dec 31, 2020

I'm sorry for the issues that happened with the last try to redirect the release thanks to Spigotmc's Cloudflare setup.
This is not a new version (well it is, but nothing changed, it's just to fix issues that happen thanks to Spigotmc's versioning setup), so there is no need to update to this!

The main download of the NBT-API has moved over to CurseForge. This is done for the following reasons:

- Spigotmc keeps having issues with DDoS/endless Cloudflare loading/exceptions on their end when trying to download/post something.

- CurseForge check the uploaded jars for malicious content

- They have a Reward Program where the developer gets a cut of the ad revenue, based on the project's popularity

- Better overview of which release works on which versions

- I'm currently also doing a lot of Fabric/Forge development, and it makes it simpler to have all downloads under the same roof.

I'll also take this as an opportunity to improve the Github developer wiki since the project description here on Spigotmc has become too big and not understandable enough.

To make it clear, no, the NBT-API won't leave Spigotmc, only the primary download will be over at CurseForge.

In case you can't or don't want to download from there, you can still access the GitHub releases ( https://github.com/tr7zw/Item-NBT-API/releases), Maven Repo ( https://repo.codemc.io/#browse/browse:maven-public:de/tr7zw/item-nbt-api-plugin) or Jenkins ( https://ci.codemc.io/job/Tr7zw/job/Item-NBT-API/).
----------, Dec 20, 2020

1.16.4 maintenance release:
  • 1.16.4 support
  • Setter for shaded versions of the API to replace the logger
----------, Nov 3, 2020

A bigger update containing the following changes:
  • 1.16.2 support
  • Implement utility methods for merging NBT (By @SoSeDiK)
  • Improved TileEntity support in 1.16+
  • Full (as far as possible) 1.7.10 support
  • NBTInjector will now print a message instead of trying to load in invalid versions
  • Adding a "Direct Apply" mode where you don't have to use getItem after modifying
----------, Aug 14, 2020

A small release to add full support for 1.16.1(No API changes). Thanks to @LoneDev for the help!
----------, Jun 25, 2020

A quick bugfix update without API changes:
  • Added the api-version 1.13. Only >= 1.13 uses this so it doesn't use legacy materials, which broke newer materials in NBTItems. Fixes #74
  • The version check was doing an HTTP request in the main thread, which was fine for the plugin version since it happened during enable, but shaded versions might do that sometime later when players are online, causing a short lag.
----------, Apr 9, 2020

Maintainance before 1.16 releases that fixes a few bugs here and there and adds some small new features.

  • Fixed the possibility that a broken test file causes the onEnable self-check to always fail
  • Added PersistendDataContainer API for Tiles and Entities. This replaces the NBT-Injector which won't get (maintained) support for 1.16. This API is usable for 1.14+, older versions have to use the NBT-Injector. You can use the 1.14/1.15 as transition period.
  • Added the NBTGameProfile class for converting GameProfiles from and to NBT
  • Fixed a problem in the 1.13 NBT-Injector
  • Added Streaming API. This adds to all NBTCompounds writeCompound(OutputStream) and to NBTContainer the constructor NBTContainer(InputStream inputsteam)
  • Added missing List types
  • Added more null/invalid state checks so null/air Items/dead entities/not placed tiles will throw an exception
  • You can now compare 2 compounds using equals (toString is used for the content)
  • Added (WIP) data API. Will become more useful in the future by providing Spigot like API for normally unreachable stuff.
----------, Apr 2, 2020

Update to 2.2.0 to fix a few somewhat critical bugs, add awesome new features and also to wish a happy new year to everyone!
  • Fixed NBT-Injector for 1.15.*
  • Throws exception when the Injector is used without enabeling it first
  • Added Java 11+ support! (Reflections where broken)
  • ListCompounds now extend NBTCompounds, enabeling all compound methods for them!
    • Nesting Compound Lists is now possible!
  • ToString Method now uses asNBTString()
    • asNBTString() got depricated
  • Fix List's Iterator/ListIterator off-by-one Error! (First element got skipped!)
  • ListIterator's previous() was wrong
  • Added Updatecheck that will log during startup rather there is a newer/older version
    • Also prints the package to identify outdated shaded api versions
  • Added working toString to lists
  • bStats was failing when loaded async
  • NBTItem.convertNBTtoItem(comp) used the root of the Compound, not the actually given one!
  • Added setItemStack and getItemStack methods to NBTCompounds as simple helper methods
----------, Dec 31, 2019

Update to 2.1.1
  • Add missing Entity mappings for 1.14
  • 1.15 Update
----------, Dec 13, 2019

Update to 2.1.0:
  • Fixed 1.12/11 invisible mobs
  • Fixed an NBTInjector exception that could happen in 1.13.2
  • If reflections were unable to get their hook, an NPE was thrown because the logger wasn't yet initialized
  • The NBTInjector won't enable by default, enable it during onLoad if you want to use it
  • Prevent /reload when the NBTInjector is enabled to prevent corrupt server states
!!! The NBTInjector is now disabled by default. You must enable it during onLoad with NBTInjector.inject();, else chunks will be loaded without injected entities and all custom saved data on tiles/entities gets lost !!!
----------, Sep 23, 2019

After much work the 2.0.0 of the NBTApi (dropped the Item part where possible) is done! Changelog:
  • inventivetalent donated the new module "NBTInjector" that now makes it possible to save custom tags to Tiles and Entities!
  • Many performance/bug/consistency fixes
  • Moved from Jitpack to CodeMC (Don't use the old repo!)
  • The entire public codebase is now documented, so make sure Maven/Gradle pull the javadocs!
  • Instead of silently failing all methods are now throwing unchecked NbtApiException's
  • NBTList's now implement the java List interface to make them useable in combination with other code
  • Updated the Spigot page with more examples, usage and infos
  • bStats is now inside the API instead of the plugin, so it even works when shaded
  • Shading now requires relocating the packages to prevent conflicts between plugins with different versions
  • The new plugin name for dependencies is "NBTAPI" and the package changed to "de.tr7zw.nbtapi"("de.tr7zw.changeme.nbtapi" when working with the not yet shaded+relocated api). The 2.0.0 version can be run at the same time as the 1.8.x versions to allow outdated plugins that still need "ItemNbtApi" to work
  • Reworked the startup tests to provide better output and be better extendable

Feel free to join the Discord in case you need help with updating or the new NBTInjector.
----------, Aug 3, 2019

This small update adds 1.14 support (Only NBTLists had a problem)
----------, Apr 24, 2019

This version patches 3 small errors:
If you notice any other oddity or exception please open an issue on Github or via pn.
----------, Sep 25, 2018

The method .hasKey had the potential to return null instead of true/false. Now will default to false in that case.
----------, Aug 30, 2018

This update adds the 1.13.1. Also some 1.13+ bugs related to Tiles/Entities have been fixed, and all unnamed methods (That are just called "a", "b"..) are now in the new reflection system to speed up Minecraft updates. Tested with 1.8.8-1.13.1, like always not toooo sure about 1.7.10.

If you still notice anything odd please pn me on spigot or open an issue on Github. Also if this resource helps you feel free to donate a coffee using the donation link :).
----------, Aug 29, 2018

This Beta release (it's still work in progress, but works) is a rewrite of the internal workings of the NBT-API. So far the rewrite has added-up to removing 400 lines while keeping all functions and making the code better maintainable. I was able to add 1.13 support into this build in about 30 minutes of work, so the cleared code paid out.
Featurelist:
  • All (finished migrating) reflections get checked at plugin start, so all "Class not found" and "Method not found" will show up at startup
  • 1.13 support
  • Improved performance and less GC heavy by caching all Reflections
This build has had it's startup test ran against 1.8.8-1.13 without error. 1.7.10 spat out some errors (as expected), but since only 2 servers are using 1.7.10 this will be pushed back to be fixed.
----------, Jul 18, 2018

This update allows you to read/write nbt files. It can be used as an alternative to saveing data in yml format.
Example:
Code (Text):
 NBTFile file = new NBTFile(new File(getDataFolder(), "test.nbt"));
            file.addCompound("testcomp");
            file.setLong("time", System.currentTimeMillis());
            file.setString("test", "test");
            file.save();
----------, Dec 6, 2017

This update doesn't add new stuff, but adds support for 1.7 servers.
Notes: Use a 1.7 with R4 (1.7.10), NBTLists may not work, everything using Gson is disabled(Add Gson before the NBTAPI loads, to turn it back on) and you can't get the NBTTypes, because 1.7 is missing this feature.
----------, Aug 13, 2017

This huge update adds to NBTItem the following new supported classes: NBTEntity and NBTTileEntity! You are able to change all data they contain! Sadly it isn't possible to add custom tags to them.(They will just vanish!)

Changes:
  • You can now access into the folder like structures of NBT Tags using the Compound methods
  • Using the toString() method on NBTItem/NBTEntity/NBTTileEntity returns a tree structure of all NBT tags
  • Added many new supported data types like Bytes, IntArray, ByteArray, Lists(String and Compound Lists)
  • Changed from MCStats to bStats
  • Currently the 1.7 support is removed!
  • 1.12 support
  • These changes allow you to access and change basiclly all NBT data of Items/Entities/TileEntities! (Yes all vanilla tags are reachable)
  • Easy class to check the servers version (MinecraftVersion)
----------, Jun 29, 2017

It's now directly possible to save Objects into items via Gson (Thanks spaarkimus). Also, it's now possible to use NBTTagCompounds like folders. Technically this makes it even possible to access some more Vanilla tags. (A real implementation to have easy access to tags spigot is currently missing is planned :))
----------, Feb 4, 2017

Sorry for the fast update after the last one.
Fixes https://github.com/tr7zw/Item-NBT-API/issues/2 by merging https://github.com/tr7zw/Item-NBT-API/pull/3 created by leMaik.
----------, Nov 7, 2016

Added:
  • removeKey(String key); returns void
  • getKeys(); returns Set<String>
Tested in versions:
  • 1.7.10 (Why are you still using 1.7?!?)
  • 1.8.8
  • 1.9
  • 1.9.2
  • 1.9.4
  • 1.10
  • 1.10.2
Notes:
Using setString("key", null); acts like remove("key");
----------, Nov 7, 2016

Merged changes made by synquall. Also confirmed that the plugin is working in 1.9!
Changelog: https://github.com/tr7zw/Item-NBT-API/pull/1
----------, Mar 11, 2016

Simple "hasKey(String)" function.
----------, Jun 7, 2015

Resource Information
Author:
----------
Total Downloads: 213,306
First Release: Jun 7, 2015
Last Update: Dec 16, 2024
Category: ---------------
All-Time Rating:
107 ratings
Find more info at github.com...
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings