When I open the inventory I set all the items to be dark green glass. When I reload it and open the inventory it is just green glass. What check do I need to do to not make it glass. Code (Text): invC.setItem(0, glass); invC.setItem(1, glass); invC.setItem(2, glass); invC.setItem(3, glass); invC.setItem(4, glass); invC.setItem(5, glass); invC.setItem(6, glass); invC.setItem(7, glass); invC.setItem(8, glass);
If you are talking about returning the items to the inventory, you would have needed to to have saved a copy of the original inventory and restore the inventory using that copy.
No because when I open the inventory set the items to be glass but I need a check to see if there was an item
Basically, when you first get the plugin the inventory(Custom GUI) Is full of glass. When you click on a glass it is replaced with the item in your hand. When you add an item to the inventory the items in the inventory are stored in the config. When I reload and go into the inventory there gone(the items) But the glass is still there. Then I need to make randomly choose one of the items based on a percentage which is set in /additem <percentage> . the command brings the gui up.
Maybe you post your whole code here and not just one function. No one can find errors in your code, if we dont see the code.
Saving to Config: Code (Text): ItemStack[] armorArray = invC.getContents(); int id = 0; for(ItemStack item : armorArray){ Main.inst().getConfig().set("Common.Items." + id + ".item", item.toString()); Main.inst().getConfig().set("Common.Items." + id + ".percentage", AddItem.getInstance().percentage); id++; } Main.inst().saveConfig(); Setting Inventory when opening inventory: Code (Text): @EventHandler public void invClick(InventoryClickEvent e) { Inventory inventory = e.getInventory(); Player p = (Player) e.getWhoClicked(); if(inventory.getTitle().equals(ChatColor.BLACK + "*Kisses DessieYT*(Admin Crates)")){ if(e.getCurrentItem().getType() == Material.TOTEM){ if(e.getCurrentItem().isSimilar(AddItem.getInstance().totemc)){ p.closeInventory(); p.openInventory(invC); /*if(!(invC.getItem(0).getType() == Material.STAINED_GLASS_PANE)){ return; } if(!(invC.getItem(1).getType() == Material.STAINED_GLASS_PANE)){ return; } if(!(invC.getItem(2).getType() == Material.STAINED_GLASS_PANE)){ return; } if(!(invC.getItem(3).getType() == Material.STAINED_GLASS_PANE)){ return; } if(!(invC.getItem(4).getType() == Material.STAINED_GLASS_PANE)){ return; } if(!(invC.getItem(5).getType() == Material.STAINED_GLASS_PANE)){ return; } if(!(invC.getItem(6).getType() == Material.STAINED_GLASS_PANE)){ return; } if(!(invC.getItem(7).getType() == Material.STAINED_GLASS_PANE)){ return; } if(!(invC.getItem(8).getType() == Material.STAINED_GLASS_PANE)){ return; } */ invC.setItem(0, glass); invC.setItem(1, glass); invC.setItem(2, glass); invC.setItem(3, glass); invC.setItem(4, glass); invC.setItem(5, glass); invC.setItem(6, glass); invC.setItem(7, glass); invC.setItem(8, glass); //glassCommon(); } } } Placing Items from config into inventory in onEnable(): Code (Text): List<ItemStack> listitems = new ArrayList<>(); for (String s : getConfig().getConfigurationSection("Common.Items").getKeys(false)) { listitems.add(getConfig().getItemStack("Common.Items." + s + ".item")); } ItemStack[] array = listitems.toArray(new ItemStack[listitems.size()]); InvCLickAdmin.getInstance().invC.setContents(array);