Hot Summer Deals are Here!
Celebrate with up to 99% off on 17,500 resources
02
Days
07
Hours
03
Mins
57
Secs

Item (de)serializing (Need help)

Status
This thread has been locked.

SubSide

¯\_(ツ)_/¯
Premium
Feedback score
0
Posts
165
Reactions
68
Resources
0
I don't know where else I could put this,
but does someone know how to (de)serialize itemstacks to and from json?
ItemStack.deserialize and serialize work fine for YAML, but for json it gives on deserialization a ClassCastException:
java.lang.Long cannot be cast to java.lang.Integer
Anyone know a way? =)

05.04 10:25:59 [Server] WARN at org.bukkit.inventory.ItemStack.deserialize(ItemStack.java:525)
05.04 10:25:59 [Server] WARN java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

SubSide

¯\_(ツ)_/¯
Premium
Feedback score
0
Posts
165
Reactions
68
Resources
0

Thanks for your response,
The problem is that it happens on deserialization in bukkit code itself:

Code:
inv.setItem(Integer.parseInt(key+""), ItemStack.deserialize((Map<String, Object>)lootItems.get(key)));
(It happens on ItemStack.deserialize((Map<String, Object>)lootItems.get(key)) btw)
 

Jack

Retired Moderator
Supreme
Feedback score
11
Posts
1,209
Reactions
1,462
Resources
0
Thanks for your response,
The problem is that it happens on deserialization in bukkit code itself:

Code:
inv.setItem(Integer.parseInt(key+""), ItemStack.deserialize((Map<String, Object>)lootItems.get(key)));
Yeah sorry then, just don't know enough about Bukkit to be able to help :(
 

SubSide

¯\_(ツ)_/¯
Premium
Feedback score
0
Posts
165
Reactions
68
Resources
0
Yeah sorry then, just don't know enough about Bukkit to be able to help :(
No problem ;)
At least you tried :p

If I don't have a good solution for it tomorrow, I'll propably have to use some "hacky" way,
Ofcourse I'd rather use the code bukkit provides though.
 

SubSide

¯\_(ツ)_/¯
Premium
Feedback score
0
Posts
165
Reactions
68
Resources
0

Young_Explicit

Owner & Lead Developer @ Minerize and MCTeams
Premium
Feedback score
1
Posts
123
Reactions
54
Resources
0
As far as I know, there's no easy way to do this. Especially if you want to serialize Item Meta, Enchantments ect
 

SubSide

¯\_(ツ)_/¯
Premium
Feedback score
0
Posts
165
Reactions
68
Resources
0
Status
This thread has been locked.
Top