GithubHelp home page GithubHelp logo

henryloenwind / autosave Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sleepytrousers/autosave

0.0 2.0 0.0 225 KB

Automatically save, load, and sync NBT data with a easy to use, easy to extend, annotation based API.

Java 100.00%

autosave's Introduction

AutoSave CircleCI branch

Automatically save, load, and sync NBT data with a easy to use, easy to extend, annotation based API.

How To Use

Label your fields

Simply annotate any fields that need to be saved with @Store.

public class MyObject {
    
    @Store
    private String name;
    
    @Store
    private int counter;
}

Serialize With Ease

The (de)serialization API is very simple, only a single line of code!

To write an object to NBT:

NBTTagCompound tag = new NBTTagCompound();
Writer.write(tag, object);

To read an object from NBT:

Reader.read(tag, object);

Automatic recursive serializer support

@Storable
public class StorableExample {
    
    @Store
    private String name;
}

public class Wrapper {
    
    @Store
    private StorableExample storable;
}

Writer.write(tag, new Wrapper()); // This will work!

Extend the supported field types

Registry registry = new Registry();
registry.register(new HandleMyObject());

...

class Wrapper {

    @Store
    private MyObject myObject = new MyObject();
}

NBTTagCompound tag = new NBTTagCompound();
Writer.write(registry, tag, new Wrapper());

Out-of-the-box Supported Types

Special Cases

  • Array types will automatically look for a handler for their component type
  • Supported generic types will do the same (List, Map, etc. See Java)

Java

  • All primitive types (including boxed types)
  • String
  • Enum
  • List (ArrayList)
  • LinkedList
  • Set (HashSet)
  • Map (HashMap)
  • EnumMap
  • Enum2EnumMap (Not a class, but a special case of EnumMap where the data is packed more efficiently)

Minecraft

  • BlockPos
  • Block
  • IBlockState
  • Item
  • ItemStack
  • ResourceLocation

Forge

  • Fluid
  • FluidStack
For more information, refer to the javadocs.

autosave's People

Contributors

tterrag1098 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.