Home›Java›Mods›[Java] SaveableSerialize
ModsJava

[Java] SaveableSerialize

Java mod listed for Minecraft 1.7–1.12. Download on the author's site.

⬇ Download on Spigot
SaveableSerializing is...


Text based serializing system focused on speed and readability.
SaveableWriter executes serialization with like next format .

start subset
items
end subset


SaveableReader basically allows 250 deep of inner class.
This can change about create saveable object,
but we don't recommanded that because of over 250 section waste many memory.

Basic package of project is milkyway.SaveableSerializing.Parser
You can read Saveable Serialization after copy that package "to" your project.
ItemStack is Example Package, and contains ItemStack Serialization of lower 1.5.2 Minecraft ItemStack.
We will support higher 1.5.2 ItemStack Serialization, and we are in progress.
If you use lower 1.5.2 Serialization,ItemFlag can be ignored.
If you want to use ItemStack Serialization,Copy milkyway.SaveableSerializing.ItemStacks on your package with Default Saveable project.

If you need custom serializing class on this system.you have to implements SaveableData and register Instance to StaticSaveableRegistry.

This system follows MIT Lisence.
You are free at distribute and edit,and commercial use,
but you must make the copyright notice and permission mark on all copies or important parts of the software.
In addition, milkyway0308, the creator of this system, is not responsible for any problems with the use of the software without project bugs.


Simple Example here.

Data Saving Code
Code (Text):
HashMap<String,Integer> exampleHashMap = new HashMap<>();

SaveableDataWriter writer = new SaveableDataWriter(new File("Example.data");
try{
   writer.add(new SaveableHashMap( exampleHashMap));
catch(Exception ignored){}
writer.flush();

Data Loading Code
Code (Text):
HashMap<String,Integer> exampleHashMap = new HashMap<>();
// Current version(0.6.2) not contains FileNotFoundException ignore
File file = new File("Example.dat");
if(file.exists()){
  SaveableDataReader reader = new SaveableDataReader(file);
  List<SaveableData> data = reader.read();
  exampleHashMap = (HashMap<String,Integer>)data.get(0).getOriginal();

}
Example Custom Serializing
Code (Text):
  // You must implements SaveableData to Serialize class.
public class Test implements SaveableData{

// I will serialize this to variable at this time.
List<String> toSave = new ArrayList<>();
String data;
   // You must need empty constructor to register instance.
   public Test(){}
// Serializing start method.
// On data Serialize,this method will be invoke.
@Override
    public void writeBy(StringBuilder builder) {
       // When you write default java data,you have to seperate data with escape charactor like this.
        builder.append(data).append("\n");
        try {
           // SaveableData#appendSubSet(StringBuilder builder) method call SaveableData#writeBy(StringBuilder builder)
           // with regular format.
            new SaveableArrayList(toSave).appendSubSet(builder);
        } catch (CollectionsNullException e) {
            e.printStackTrace();
        } catch (TypeNotSupportedException e) {
            e.printStackTrace();
        }
    }

   // This method will invoke at read Object after called SaveableData#appendObject(SaveableData data).
    @Override
    public void appendTo(List<String> builded) {
        try{
           // String data will be return by writing ordered.
            data = builded.get(0);
        }catch (Exception ex){}
    }


    // SaveableData instance seperator.
    // System will seperate Object with this name.
    @Override
    public String getName() {
        return "Test";
    }

    // This method will be invoke while reading SaveableData.
    @Override
    public void appendObject(String str, SaveableData data) {
        toSave = (List<String>) data.getOriginal();
    }


    // This method use to return data without class casting.
    @Override
    public Object getOriginal() {
        return null;
    }

    // Important : You have to return empty instance at this method.
    @Override
    public SaveableData getNewInstance() {
        return new Test();
    }


}
public class Main {

    public static void main(String[] args){
      // You have to register instance before use SaveableDataReader.
        StaticDataRegistry.getHandle().registerSaveable(new Test());
        File file = new File("test.example");
        SaveableDataWriter writer  = new SaveableDataWriter(file);
        writer.add(new Test());
        // Write and Clear Writer.
        writer.flush();
       // Current version not contains FileNotFoundException ignore.
        if(file.exists()){
           SaveableDataReader reader = new SaveableDataReader(file);
            // Congratulation! You has been successed for serializing custom class.
           Test test = (Test)reader.read().get(0);
    }
}
 
Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

[Java] SaveableSerialize is a free Minecraft Java mod. Compatible with Minecraft 1.7, 1.8, 1.9, 1.10 and newer. Downloaded 105 times (via Spigot). Download it and open it directly in the game.

Explore more