Solved ArrayStoreException on ItemStack addition to Inventory

Discussion in 'Plugin Development' started by thapengwin, Jul 5, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    thapengwin

    Hey,
    upon adding an ItemStack to an Inventory, I get an ArrayStoreException - stacktrace here:
    http://pastebin.com/8qkQhKDR

    The ItemStack gets added here:
    https://github.com/StashCat/Credits.../java/co/stashcat/credits/GUIManager.java#L33
    (the line was moved by one due to recent commits)

    Weirdly enough, it's called as an ItemStack right before addition, but it still becomes a string, at least according to the stacktrace. I am completely stumped, and would appreciate any assistance - thank you beforehand!
     
    Last edited: Jul 15, 2016
  2. Offline

    ArsenArsen

    Did you test on a different version?
     
  3. Offline

    thapengwin

    Tested on the latest Spigot 1.10.2 build as of 05/07/2016 19:53, not working
    1.9.4, exactly the same

    I at one point thought that this might be caused by ItemStack binding a lore and it containing incorrect values, but after deleting any lines mentioning a lore it still causes the same. I repeated the process with any other metadata variables and nothing changed.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 5, 2016
  4. Offline

    ArsenArsen

    Why do you even use enums to store these?
     
  5. Offline

    thapengwin

    @ArsenArsen excuse me? I don't remember using enums in this plugin
     
  6. Offline

    ArsenArsen

  7. Offline

    thapengwin

  8. Offline

    ArsenArsen

    Oh, nvm. Sorry
     
  9. Offline

    thapengwin

    This is still an issue, bump.
     
  10. ArrayStoreException is thrown when you try to put the wrong object into an array, are you sure that method actually takes an ItemStack?
     
  11. .
     
    Last edited: Jul 15, 2016
  12. Offline

    thapengwin

    It instantiates an ItemStack with getMaterial, for which the sting is taken from storage and stores it as an ItemStack. Shouldn't that cause an error in that section of the code instead if that's the issue?
    I also redefine the ItemStack again right before putting it into the Inventory. That as well should cause an error.
     
  13. @thapengwin
    I don't know what I was really thinking.. maybe you're inputting something that extends ItemStack?
     
  14. Offline

    thapengwin

    Well, the only issue there might be is the material name, which I currently input manually... But I digress, the material strings match up with the enums, and it would give a different error.
    It initialises an ItemStack from a Material, then the ItemStack is retrieved and put into the Inventory, at which point the error occurs.
     
  15. Wait I am a derp, it says its a string you're trying to put into the array. Although I have no idea how there is a string. Must be something to do with the internal classes of bukkit.
     
  16. Offline

    thapengwin

    That is what I'm interested in - is this a Spigot bug or did I screw up somewhere? It's definitely not the metadata screwing up, as I removed that part entirely, yet it still caused an exception. If I am able to recreate this on a fresh plugin I will create a bug report on Spigot's tracker.
     
  17. Offline

    thapengwin

    THE SAGA ENDS.
    I have finally figured out what the cause of this is. You won't believe how long I spent trying to fix this, and the issue was merely using a material that no longer exists in the game. That's the cause of the ItemStack being a String, even though it should be null...
     
Thread Status:
Not open for further replies.

Share This Page