Solved custom inventory only shows 1 item inside it and ignores custom names.

Discussion in 'Plugin Development' started by Athyk, Jan 16, 2017.

Thread Status:
Not open for further replies.
  1. when I run this command to create a GUI (custom inventory) It only shows the inventory with its custom name and with the BARRIER inside it, but with no custom name and where is the nether wart?

    please help!

    my code is as follow:
    Code:
            // Create manager
            Inventory manager = Bukkit.createInventory(null, 9, "Manager");
    
            // Create items
            ItemStack bloodParticle = new ItemStack(Material.NETHER_WARTS, 1);
            ItemMeta bpm = bloodParticle.getItemMeta();
            bpm.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&cBleeding"));
            ArrayList<String> lore = new ArrayList<String>();
            lore.add(ChatColor.translateAlternateColorCodes('&', "&7Shows a bleeding effect."));
            bpm.setLore(lore);
            bloodParticle.setItemMeta(bpm);
    
            ItemStack closeManager = new ItemStack(Material.BARRIER, 1);
            ItemMeta cmm = bloodParticle.getItemMeta();
            cmm.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&cExit"));
            ArrayList<String> lore2 = new ArrayList<String>();
            lore2.add(ChatColor.translateAlternateColorCodes('&', "&7Close the manager GUI."));
            cmm.setLore(lore);
            bloodParticle.setItemMeta(cmm);
    
            // Load options
            manager.setItem(0, bloodParticle);
            manager.setItem(8, closeManager);
    
            player.openInventory(manager);
     
  2. Offline

    Sethburster

    I notice that after you make the closeManager Item Meta, you don't set the closeManager to the cmm. Instead you set the bloodparticle item meta to the cmm. Which basically is overwriting the blood particle meta you made. Not quite sure why the name isn't showing though .

    And when you are making what I assume is the closemanagermeta aka cmm, you're getting the blood manager items meta. Instead of the closeManager item


    Sent from my iPhone using Tapatalk
     
  3. Offline

    JanTuck

    Nether warts item material should be Material.NETHER_STALK

    Sendt fra min ALE-L21 med Tapatalk
     
  4. oh, lol... totally didn't see that haha. Thank you!

    Thanks for the feedback, gonna change it!

    Its working now, I also forgot to change the lore... I am stupid, haha.. thanks guys!

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

Share This Page