Solved After reloading custom config, ItemStack[] not working as It should

Discussion in 'Plugin Development' started by H7KZ, Dec 15, 2021.

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

    H7KZ

    hey, I save data about gifts to a config file. It is stored in ItemStack[]... when I do not reload it, It works perfectly fine but after reload of jar file & config It cannot read properly the ItemStack[]

    My code for saving:
    Code:
    ItemStack[] cont = contents.toArray(new ItemStack[0]);
    GiftDatabase.get().set(giftUUID + ".contents", cont);
    
    My code for accessing:
    Code:
    ItemStack[] cont = (ItemStack[]) GiftDatabase.get().get(loreList.get(1) + ".contents");
    
    World world = p.getWorld();
    
    p.getInventory().remove(e.getItem());
    
    for (ItemStack item : cont) {
    System.out.println("OK");
    if (p.getInventory().firstEmpty() == -1) {
    world.dropItem(p.getLocation(), item);
    } else {
    p.getInventory().addItem(item);
    }
    }
    
    The error after reload when accessing gift's contents:

    [21:17:16] [Server thread/ERROR]: Could not pass event PlayerInteractEvent to Gifts v1.0-SNAPSHOT org.bukkit.event.EventException: null
     
    Last edited by a moderator: Dec 16, 2021
  2. Offline

    timtower Administrator Administrator Moderator

    @H7KZ Need the full error to say anything meaningful.
     
  3. Offline

    H7KZ

    Hey I found where the mistake is! It is in the storing it self! When storing ItemStack[] it is stored something like this: { something @ some random letters} but AFTER THE RELOAD it is stored like this: {ItemStack: Item...., ItemStack: Item...} or something like that idk right now so I used List of ItemStacks and that seems to fix it.
     
Thread Status:
Not open for further replies.

Share This Page