Hi dev fellows, I've encountered some problem. I need to save an itemStack into a String But serialize return me a Map (having inside another map for enchantment for example) Do you have some idea ? Thanks in advance, Rominos2
One solution is to use Gson. It is included in bukkit. // Writing: MyObject obj = blahblahblah; Gson gson =new Gson(); String objStr = gson.toJson(obj); save(objStr); // Reading: String objStr = read(); MyObject = gson.fromJson(objStr, MyObject.class); You can modify my plugins WriterReader.java: https://github.com/andfRa/Saga/blob/master/src/org/saga/saveload/WriterReader.java if you want. You only need to change Directory enum values.
andf54 Hmm that sounds great. I'll test it. Thanks EDIT : It provides strings too long but I'll test some other ways not saving the ItemStack but number, the data, and the enchantements one after the other (less long string)