My code is not working, need someone with some distance to my project to look throught

Discussion in 'Plugin Development' started by Kostronor, Aug 23, 2011.

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

    Kostronor

    Hey,
    I was writing a plugin that gets ItemStacks from a chest and saves them in a HashMap from where they are loaded again when the chest is opened (yes, the chest is virtual).
    The problem is: to save them, i wanted to use Serializable, but ItemStacks do not support that, so i store the data in self made formats. Everything is working as intended but in the process of saving the ItemStack to the HashMap and collecting it back is somewhere a perhaps very tiny error which results in a loss of every ItemStack except the first one.
    Here is my code:
    https://github.com/SirDrakeHeart/Construction-Sites/blob/master/src/en/trudan/ConstructionSites/Data/MaterialStorage.java
    to get the content of the HashMap i call getChest() to save I call addMaterial(Itemstack).
    Help is appreciated :)
     
  2. Offline

    pmx

    Maybe post your code to gist? The forum really messed it up! lol
     
  3. Offline

    Kostronor

    changed :D
     
  4. Offline

    CptSausage

    Not sure if I get your code correctly but shouldn't it be
    Code:
    chest[i] = is;
    instead of
    Code:
    chest = is;
    ?
     
  5. Offline

    Kostronor

    ItemStack[] chest = new ItemStack[54];
    so i take one ItemStack out of my chest.

    I got a solution from Dykam in IRC, will try that first :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  6. Offline

    CptSausage

    Hm I don't get it. :/

    How does this even work? Shouldn't you get an 'incompatible types' error? Or is this some tricky stuff you can do with java?
    Code:
    ItemStack[] chest = new ItemStack[54];
    ItemStack is = new ItemStack[bla];
    chest = is;
     
  7. Offline

    Kostronor

    i create an Array of Itemstacks with a size of 54.
    So chest is 54 Itemstacks
    and the i pull the ItemStack at i to is to work with a single ItemStack
     
Thread Status:
Not open for further replies.

Share This Page