How to add custom block, itemstack and entity data that is persistent?

How to add custom block, itemstack and entity data that is persistent on restarts? The old bukkit days, you had to use lore to add custom itemstack data that is persistent and for block, you need to save the location of the block along with your custom data and check if the block interacted was on that location to read that data. Is there a better way to do it in Sponge? If so, I might just move all of my projects in Sponge as It gets repetitive and really inefficient to save each data on a file.

For example, this is the plugin I am working on. Look at that sword lore. It looks really untidy.

My Plugin with lore to get custom itemstack data

I managed to make the lore data invisible but I would prefer if Sponge had a way to manage persistent data.

1 Like

The DataAPI has yet to be entirely implemented. @gabizou could probably explain the DataAPI better than anyone. :stuck_out_tongue:


Use the Data API -

Edit @FerusGrim ninja’d me by 36 seconds :open_mouth:


I want to know this as well.

Is it persistent on restarts?

If the data is accepted, yes.
See the DataHolder#offer method

Thanks for that Simon. Do you also know what data types are allowed?

You can try to offer it any type of data. Just check the returned DataTransactionResult to see what happened.

Alright, thanks a lot. I will try it and if anything goes wrong, I would be sure to let you know.