Solved Bukkit serializer

Discussion in 'Spigot Plugin Development' started by FiXed, May 24, 2016.

Thread Status:
Not open for further replies.
  1. So yes this might be a common question that's been answered but I haven't really found a way to get this answer. I've looked into this and was wondering if it was right:
    Code (Java):
        public final void serialize(ItemStack item) {
            getConfig().set("test-name", item.serialize());
        }
     
        public final ItemStack derserialize() {
            Map<String, Object> args = new HashMap<String, Object>();
            for(String string : getConfig().getConfigurationSection("test-name").getKeys(true)) {
                args.put(string, getConfig().get("test-name." + string));
            }
            return ItemStack.deserialize(args);
        }
    I'm pretty sure it's wrong but could someone give me some pointers as to how to use this? Or should I use it like this:
    Code (Java):
        public final void serialize(ItemStack item) {
            getConfig().set("test-name", item.serialize().toString());
        }
     
        public final ItemStack derserialize() {
            return getConfig().getItemStack("test-name");
        }
    Or is that still wrong? I've never serialized an item before.
     
  2. Okay it works, I am eternally grateful <3
     
    • Like Like x 1
Thread Status:
Not open for further replies.