I'm pretty sure i did this before, but i don't remember how. Say i had this in a file Code: Contents: '0': ==: org.bukkit.inventory.ItemStack type: DIAMOND_SWORD meta: ==: ItemMeta meta-type: UNSPECIFIC display-name: 'name ' enchants: FIRE_ASPECT: 2 repair-cost: 2 '1': ==: org.bukkit.inventory.ItemStack type: ANVIL '2': ==: org.bukkit.inventory.ItemStack type: DIAMOND_SWORD amount: 3 meta: ==: ItemMeta meta-type: UNSPECIFIC display-name: 'name ' lore: - "\xa7rhi" enchants: FIRE_ASPECT: 2 repair-cost: 2 As you can infer, those are serialized itemstacks i saved (thanks nverdier lmao) So anyway, to get to the point, im trying to load a GUI from those itemstacks. How do i get all the itemstacks in the path "Contents?" I tried: Code: public void openWeaponShop(Player p) throws IOException { MenuMaker menu = new MenuMaker(plugin, "Weapon Shop", 5); File file = new File(plugin.getDataFolder(), "weaponshop.yml"); if(!(file.exists())) try { file.createNewFile(); } catch (IOException e1) { e1.printStackTrace(); } FileConfiguration items = YamlConfiguration.loadConfiguration(file); List<ItemStack> contents = ((List<ItemStack>) items.get("Contents")); for(ItemStack n: contents) { menu.addItem(n); } menu.showMenu(p); } (I am adding the items to the inventory correctl
@DogeDebugger it's the serialize method from bukkit, so yea, there is. loops the configuration section 'contents' and config.getItemStack(path);
Code: public void openWeaponShop(Player p) throws IOException { MenuMaker menu = new MenuMaker(plugin, "Weapon Shop", 5); File file = new File(plugin.getDataFolder(), "weaponshop.yml"); if(!(file.exists())) try { file.createNewFile(); } catch (IOException e1) { e1.printStackTrace(); } FileConfiguration items = YamlConfiguration.loadConfiguration(file); ItemStack itemstack = items.getItemStack("Contents"); menu.addItem(itemstack); menu.showMenu(p); } My GUI comes up blank... Code: Contents: '0': ==: org.bukkit.inventory.ItemStack type: DIAMOND_SWORD amount: 3 meta: ==: ItemMeta meta-type: UNSPECIFIC display-name: 'name ' lore: - "\xa7rhi" enchants: FIRE_ASPECT: 2 repair-cost: 2 '1': ==: org.bukkit.inventory.ItemStack type: CAKE amount: 64 '2': ==: org.bukkit.inventory.ItemStack type: DIAMOND_SWORD meta: ==: ItemMeta meta-type: UNSPECIFIC display-name: 'name ' enchants: FIRE_ASPECT: 2 repair-cost: 2 '3': ==: org.bukkit.inventory.ItemStack type: CAKE amount: 64 '4': ==: org.bukkit.inventory.ItemStack type: CAKE amount: 64 '5': ==: org.bukkit.inventory.ItemStack type: GOLD_LEGGINGS '6': ==: org.bukkit.inventory.ItemStack type: GOLD_BOOTS '7': ==: org.bukkit.inventory.ItemStack type: GOLD_BOOTS '8': ==: org.bukkit.inventory.ItemStack type: IRON_LEGGINGS '27': ==: org.bukkit.inventory.ItemStack type: CAKE amount: 64 '28': ==: org.bukkit.inventory.ItemStack type: GOLD_HELMET '29': ==: org.bukkit.inventory.ItemStack type: CAKE amount: 32 '30': ==: org.bukkit.inventory.ItemStack type: CAKE '31': ==: org.bukkit.inventory.ItemStack type: CAKE '32': ==: org.bukkit.inventory.ItemStack type: CAKE amount: 64 '33': ==: org.bukkit.inventory.ItemStack type: CAKE amount: 61 '34': ==: org.bukkit.inventory.ItemStack type: CAKE amount: 64 '35': ==: org.bukkit.inventory.ItemStack type: CAKE
@DogeDebugger ItemStack itemstack = items.getItemStack("Contents"); what did u expect ? contents dont have itemstack as a value, it's just number. i told you to use configuration section
*sigh* poor guy section = getConfigurationSection("contents") String slotString : section.getKeys(false) itemStack = section.getItemStack(slotString)
@_Filip You forgot the path config.getItemStack("contents."+slotString); edit; oh nvm, i tot it was the creator of the thread