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


    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:
    ItemStack[] cont = contents.toArray(new ItemStack[0]);
    GiftDatabase.get().set(giftUUID + ".contents", cont);
    My code for accessing:
    ItemStack[] cont = (ItemStack[]) GiftDatabase.get().get(loreList.get(1) + ".contents");
    World world = p.getWorld();
    for (ItemStack item : cont) {
    if (p.getInventory().firstEmpty() == -1) {
    world.dropItem(p.getLocation(), item);
    } else {
    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


    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