[SPIGOT-1343] Deserialization of ItemStack fails when renamed using anvil. Created: 15/Dec/15  Updated: 15/Dec/15  Resolved: 15/Dec/15

Status: Closed
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Taylor Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: Inventory, bug
Environment:

Linux Ubuntu 14.04LTS


Issue Links:
Cloners
clones SPIGOT-1325 Deserialization of ItemStack fails. Resolved
Duplicate
is duplicated by SPIGOT-1344 Use Number instead of Double or Integ... Closed

 Description   

When calling ItemStack.deserialize, a casting exception occurs which breaks deserialization.

Unable to find source-code formatter for language: text. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at java.lang.Thread.run(Thread.java:745)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at com.lumengaming.giftwrap.service.DataService$$Lambda$16/912274127.run(Unknown Source)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at com.lumengaming.giftwrap.service.DataService.lambda$getPackageById$6(DataService.java:37)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at com.lumengaming.giftwrap.repository.MySqlDataRepository.getPackageById(MySqlDataRepository.java:131)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at com.lumengaming.giftwrap.repository.MySqlDataRepository.readPackages(MySqlDataRepository.java:158)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at com.lumengaming.giftwrap.SerializerUtility.fromJson(SerializerUtility.java:88)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at com.lumengaming.giftwrap.SerializerUtility.deserialize(SerializerUtility.java:139)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: 	at org.bukkit.inventory.ItemStack.deserialize(ItemStack.java:533)
05.12 22:57:34 [Server] INFO [22:57:34 WARN]: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer
05.12 22:57:12 [22:57:12 INFO]: Pangamma ran command Message of the Day
05.12 22:57:12 [Connect] User [22:57:12 INFO]: Pangamma, IP 127.0.0.1
05.12 22:57:12 [Server] INFO [22:57:12 INFO]: UUID of player Pangamma is f77b713b-7aa0-3854-8208-1b3550c188ca
05.12 22:53:28 [Se

The fix is to make sure the amount is being cast to Number, then the .intValue() method is used to get the int value of the amount.

if (args.containsKey("amount")) {
            amount = ((Number) args.get("amount")).intValue();
}


 Comments   
Comment by Hex [ 15/Dec/15 ]

I assume by that you mean that it was resolved. Either way it is misfiled.

Comment by Taylor [ 15/Dec/15 ]

Crap. No permissions to edit the initial post.

Comment by SpigotMC [ 15/Dec/15 ]

Your build is not the latest and therefore may be the reason you are having this issue. Spigot is 0 version(s) behind. CraftBukkit is 1 version(s) behind. This message was automatically generated and is not guaranteed to be a solution to your issue.

Generated at Sat Dec 13 15:19:01 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.