Solved Itemstacks disappearing from inventory

Discussion in 'Plugin Development' started by Tecno_Wizard, Aug 12, 2015.

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

    Tecno_Wizard

    This is driving me mad.

    I have an inventory GUI that refuses to behave.
    Code:
    Inventory iv = Bukkit.createInventory(null, 36, ChatColor.LIGHT_PURPLE + pluginPrefix);
    
            ListFile file = new ListFile("plugins" + File.separator + "CommandsForSale" + File.separator + "Players"
                    + File.separator + player.getUniqueId().toString(), "txt");
            ArrayList<String> bought = file.read();
            int pos = 1;
            FileConfiguration config = main.getConfig();
            for (ItemStack is: buyableCmds) {
                // lores of 5 is the command name
                String rawLore = is.getItemMeta().getLore().get(0);
                String [] lores = rawLore.split(" ");
                System.out.println("LORE NAME: " + lores[5]);
                if(!bought.contains(lores[5].toLowerCase())){
                    System.out.println("HAS NOT BOUGHT: " + lores[5]);
                    String perm = config.getString("CommandOptions."+ lores[5] + ".permission");
                    if ((perm.equalsIgnoreCase("void") || player.hasPermission(perm))) {
                        System.out.println("HAS PERM: " + lores[5]);
                        System.out.println(iv.addItem(is));
                        pos++;
                    }
                }
                if(pos == 36) {
                    iv.addItem(overflowIcon);
                    break;
                }
            }//end of loop through icons
            for(ItemStack is: iv.getContents())
                if(is != null) {
                    System.out.println(is.toString());
                }
            System.out.println("Done");
            return iv;
    Now when you see the console output, 2 ItemStacks were put into the inventory. They never make it in and they are not returned by Bukkit, meaning they were accepted. (Sorry about the picture. Appearently I can't copy the console. Don't ask me why)

    Does anyone see something I don't?

    upload_2015-8-12_19-32-48.png

    Solved. ItemStack materials are determined by user, but I also included materials not valid in an inventory.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
Thread Status:
Not open for further replies.

Share This Page