Skip to content

mfnalex/PersistentDataSerializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PersistentDataSerializer

Javadocs Discord Donate

Allows to serialize and deserialize Bukkit's PersistentDataContainers to and from List<Map<?,?>>s and Json, without requiring NMS.

Maven Dependency

The dependency is available on Maven Central:

<dependency>
    <groupId>com.jeff-media</groupId>
    <artifactId>persistent-data-serializer</artifactId>
    <version>1.0</version>
</dependency>

Shading

You must also shade the dependency into your plugin's .jar. Click here if you don't know how to do that.

Usage

// Serialize to Map
List<Map<?,?>>map=PersistentDataSerializer.toMapList(persistentDataContainer);

// Serialize to Json
        String json=PersistentDataSerializer.toJson(persistentDataContainer);

// Deserialize from Map
        PersistentDataContainer pdc=PersistentDataSerializer.fromMapList(pdcContext,map);

// Deserialize from Json
        PersistentDataContainer pdc=PersistentDataSerializer.fromJson(pdcContext,json);

Note: To deserialize, you need to provide a PersistentDataAdapterContext. You can get one from any existing PersistentDataContainer by calling PersistentDataContainer#getAdapterContext()

Information about MockBukkit

If you're using MockBukkit, you'll notice that serializing to Json or YAML causes issues as the MockBukkit implementation of PersistentDataContainer is buggy. It will work fine on the actual server though.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages