-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
-
Environment:
Linux Ubuntu
You can serialize itemstacks just fine into map form, and from there you can serialize those into json using google json (gson). The issue is when you go to deserialize, gson decides to parse some integers as doubles for some reason. (Let's be fair about this, a double could just as easily be saved as an int, and then be detected as an Integer on load. So it'll need to be a fix within the spigot code)
*Because you cannot cast Integer to Double, and vise versa, cast these parsed objects to Number. Then use the Number class's methods to derive doubles or integers from there.
*
http://i.imgur.com/DQPE3Md.png
Double d = 23.1; int n = ((Number) d).intValue(); double d2 = ((Number)d).doubleValue();
Server] INFO at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_45]
15.12 08:23:16 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_45]
15.12 08:23:16 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_45]
15.12 08:23:16 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem.<init>(CraftMetaItem.java:492) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
15.12 08:23:16 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem$SerializableMeta.getObject(CraftMetaItem.java:190) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
15.12 08:23:16 [Server] INFO java.lang.IllegalArgumentException: repair-cost(1.0) is not a valid class java.lang.Integer
15.12 08:23:16 [Server] INFO [08:23:16 ERROR]: Could not call method 'public static org.bukkit.inventory.meta.ItemMeta org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem$SerializableMeta.deserialize(java.util.Map) throws java.lang.Throwable' of class org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem$SerializableMeta for deserialization
15.12 08:22:55 [Server] INFO [08:22:55 INFO]: Saved the world
15.12 08:22:55 [Server] INFO [08:22:55 INFO]: Saving...
15.12 08:22:55 [Server] INFO [08:22:55 INFO]: Saving is already turned on.
15.12 08:22:55 [Multicraft] Skipped 75 lines due to rate limit (30/s)
15.12 08:22:55 [Multicraft] Auto-saving world...
- duplicates
-
SPIGOT-1343 Deserialization of ItemStack fails when renamed using anvil.
-
- Closed
-