Solved Deserializing skull returns Steve Head

Zxoir

New member
Aug 16, 2022
3
0
1
Hello, I'm currently working on a custom Lucky Block plugin and whenever I deserialize the LuckyBlock Skull item it returns a Steve Skull. Would I need to make a custom deserialize/serializing methods or is there a way to fix this? (Note: Serializing/deserializing any other item works perfectly fine)


Java:
dataFile.getConfig().set("LuckyBlockItem", adapter.toJson(LuckyBlock.getLuckyBlock() == null ? "" : LuckyBlock.getLuckyBlock().serialize()));
dataFile.saveConfig();
Java:
        if (dataFile.getConfig().getString("LuckyBlockItem") != null) {
            Map<String, Object> serializedItem = adapter.fromJson(dataFile.getConfig().getString("LuckyBlockItem"), new TypeToken<Map<String, Object>>() {
            }.getType());

            if (serializedItem != null && !serializedItem.isEmpty())
                LuckyBlock.setLuckyBlock(ItemStack.deserialize(serializedItem));
        }
Screenshot 2022-08-16 130410.png
Screenshot 2022-08-16 130452.png
 

Zxoir

New member
Aug 16, 2022
3
0
1
I'm pretty sure this is a problem with paper/spigot. BlockData doesn't seem to include the owner of skulls in their Data so whenever you want to deserialize/serialize a skull it's always going to return a Steve head
 

electronicboy

Administrator
Staff member
Dec 11, 2021
104
7
22
18
calling the de/serialise methods inside of bukkit is unsupported (You WILL lose all item meta due to how the logic works, unless you basically special-case the ItemMeta stuff), use the json configuration library if you really want json, given that it hooks into the bukkit API to serialise stuff properly, or, just use yaml config, ideally use the serialise as bytes API if purely sticking to paper
 

Zxoir

New member
Aug 16, 2022
3
0
1
calling the de/serialise methods inside of bukkit is unsupported (You WILL lose all item meta due to how the logic works, unless you basically special-case the ItemMeta stuff), use the json configuration library if you really want json, given that it hooks into the bukkit API to serialise stuff properly, or, just use yaml config, ideally use the serialise as bytes API if purely sticking to paper
Got it, thanks 👍