Multiple Items in GUI from config.yml

Discussion in 'Plugin Development' started by GazpachoYT, Apr 20, 2017.

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

    GazpachoYT

    Hey! I'm stuck and idk what to do, What Im trying to do is make it so you can add items to a GUI from inside a config

    My code:
    Code:
      public static void openGUI(Player player) {
            Inventory inv = Bukkit.createInventory(null, plugin.getConfig().getInt("FreezeGUI.InventorySlots"), ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("FreezeGUI.InventoryName")));
          
                ItemStack a2 = new ItemStack(Material.getMaterial(plugin.getConfig().getString("FreezeGUI.InventoryItems.Item1")));
                ItemMeta am2 = a2.getItemMeta();
                am2.setDisplayName(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("FreezeGUI.InventoryItems.Item1Name")));
                List<String> lore = plugin.getConfig().getStringList("FreezeGUI.InventoryItems.Item1Lore");
                List<String> coloredLore = new ArrayList<String>();
                for (String s : lore) {
                    coloredLore.add(ChatColor.translateAlternateColorCodes('&', s));
                }
                am2.setLore(coloredLore);
                a2.setItemMeta(am2);
                inv.setItem(plugin.getConfig().getInt("FreezeGUI.InventoryItems.Item1Slot"), a2);
              
            player.openInventory(inv);
        }
    What I want my config to be:
    Code:
    FreezeGUI:
      InventoryItems:
        Item1:
          ItemName: '&cI''m editable'
          ItemSlot: 4
          Item: NETHER_STAR
          ItemLore:
             - ' '
             - '&7I''m also editable!'
             - '&6Really?! Same here!!'
             - '&bGazpachoYT &3is very cool! lol jkin'
             - '&3Thank you for using this plugin!'
             - '&3make sure you rate this &a5 STARS'
             - '&3because better updates soon!'
    and then i want it to go like
    Code:
        Item2:
          ItemName: '&cI''m editable'
          ItemSlot: 4
          Item: NETHER_STAR
          ItemLore:
             - ' '
             - '&7I''m also editable!'
             - '&6Really?! Same here!!'
             - '&bGazpachoYT &3is very cool! lol jkin'
             - '&3Thank you for using this plugin!'
             - '&3make sure you rate this &a5 STARS'
             - '&3because better updates soon!'
    
    and so on....

    help?
     
    Last edited by a moderator: Apr 21, 2017
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Zombie_Striker

    timtower likes this.
  4. Offline

    GazpachoYT

    Last edited: Apr 21, 2017
Thread Status:
Not open for further replies.

Share This Page