Sueta

NBTProxy

2.1.1

NBT library for accessing NBT data on items, entities, tile entities and files.

·Plugin

Thank you for checking out NBTProxy! Please send me a PM or create and issue/PR on github ( https://github.com/MrBlobman/NBTProxy) if you have any feedback. I would greatly appreciate an feature requests or suggestions!

This library is a great resource for interacting with NBT tags. It is called NBT Proxy because it is a collection of classes that wrap nms classes that you can interact with despite the underlying implementation changing between versions. In addition to this it provides a serialization API for reading and writing custom objects to and from ItemStacks with the use of your own serializers/deserializers. This makes storing information such as pick stats very easy to do. More information on that can be found on the wiki ( https://github.com/MrBlobman/NBTProxy/wiki).

➤Server Owners
This plugin is a developer resource and a utility.

  • Another plugin may require you to use.
  • You may wish to take advantage of all of the commands for reading and manipulating NBT data on items, entities, blocks, or files!

In either case just download this and drop it in your plugins folder.

Try out the commands such as

/nbt read item

after enabling it in the config.yml.

More information on the available commands can be found on the wiki page https://github.com/MrBlobman/NBTProxy/wiki/Utility-Commands

➤Developers
To use this in your project please build against the API and not this implementation.

▶Depending on the API:
There are 2 ways to depend on the API:

Add the jar to your build path.
You can grab a prebuilt binary of the API from github on the releases tab. https://github.com/MrBlobman/NBTProxy/releases

Install to your local maven repository.
The project can be built and published with gradle.
To install it you need to clone the repository and publish it with a gradle command.

git clone https://github.com/MrBlobman/NBTProxy.git
cd NBTProxy
./gradlew publishApiPublicationToMavenLocal

If you are building with gradle add the following to your dependencies extension:

compile group: 'io.github.mrblobman', name: 'NBTProxy-api', version: '2.1.0'

For maven users you can add the following to your dependencies section:

<dependency>
       <groupId>io.github.mrblobman</groupId>
       <artifactId>NBTProxy-api</artifactId>
       <version>2.1.0</version>
       <scope>provided</scope>
</dependency>

▶Hooking into the API:
Make sure that you add "NBTProxy" to the dependencies section of your plugin.yml. Then to check if the server your plugin is running on is using an NMS version that is supported by this API you can run the following:

try {
    TagFactory factory = TagFactory.get();
} catch (UnsupportedOperationException e) {
    //Code to run if there is not a compatible version running on the server
    this.getLogger().severe(e.getMessage());
    this.setEnabled(false);
    return;
}

Please note I am looking at better ways to preform this check and there will most likely be a better way to do it in the future but either way the above code will still function the same.

▶Using the API:
There is a great example over on the github wiki (https://github.com/MrBlobman/NBTProxy/wiki) for how to take advantage of the great serialization features for ItemStacks. This is similar to how Gson's serialization works (without the reflection at the moment) and as such the class is named NBTson.

The TagFactory class (http://mrblobman.github.io/NBTProxy/docs/io/github/mrblobman/nbt/TagFactory.html) have methods for instantiating new tags as well as obtaining classes for reading, writing and appending NBT data to various things (http://mrblobman.github.io/NBTProxy/docs/index.html?io/github/mrblobman/nbt/TagFactory.html).

The javadocs for the API classes can be found here http://mrblobman.github.io/NBTProxy/docs/index.html

Similar projects

Plugin →