Question Inventory Help

Discussion in 'Plugin Help/Development/Requests' started by bubblefat_, Jun 13, 2015.

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

    bubblefat_

    So I'm making a kit PvP plugin. I want to make it so if a player has purchased the kit the kit's name is green and if they don't have it then its not. What I have done is checked in the config.yml if they own the kit to name is something if not to name it something else. But this hasn't worked.

    Here is an example item I have

    Code:
            Inventory inv = Bukkit.createInventory(null, 27, "§lSelect your Kit!");
               
                       
                       
                        
                            ItemStack item = new ItemStack(Material.IRON_CHESTPLATE, 1);
                            ItemMeta meta = item.getItemMeta();
                            meta.setDisplayName(ChatColor.GREEN + "§lKnight");
                            List<String> lore = new ArrayList<String>();
                            lore.add("§7Lore");
    
                            meta.setLore(lore);
                            item.setItemMeta(meta);
                            inv.setItem(2, item);
                               
                   
            return inv;
        }
     
  2. Offline

    Rahat

    @bubblefat_ I am not a pro at java but cant you use a if and a boolean ?
     
  3. Offline

    I Al Istannen

    @bubblefat_ You never check the config in this example. Can you show a bit more code? Because it should work that way.
     
    Nedinator likes this.
  4. Offline

    BizarrePlatinum

    @I Al Istannen @bubblefat_ there isn't even an if statement in it... How exactly is this supposed to help us with the problem?
     
  5. Offline

    bubblefat_

    @Rahat @I Al Istannen @BizarrePlatinum

    What I have done before is

    Code:
                            
    if(player.isOp()){
    ItemStack item = new ItemStack(Material.IRON_CHESTPLATE, 1);
                            ItemMeta meta = item.getItemMeta();
                            meta.setDisplayName(ChatColor.GREEN + "§lKnight");
                            List<String> lore = new ArrayList<String>();
                            lore.add("§7Lore");
                            meta.setLore(lore);
                            item.setItemMeta(meta);
                            inv.setItem(2, item);
    } else{
    ItemStack item = new ItemStack(Material.IRON_CHESTPLATE, 1);
                            ItemMeta meta = item.getItemMeta();
                            meta.setDisplayName("§lKnight");
                            List<String> lore = new ArrayList<String>();
                            lore.add("§7Lore");
    
                            meta.setLore(lore);
                            item.setItemMeta(meta);
    }
    
    And the item doesn't spawn
     
  6. Offline

    BizarrePlatinum

    @bubblefat_ I'm gonna assume that the color code is working there, but it's much safer just to use chat color and a lot easier. In that instance, the item would only be in the inventory if the player is op (you did not set the item in both), and I don't really see why it wouldn't work (for ops), that code is correct (a bit inefficient).
     
    Last edited: Jun 15, 2015
Thread Status:
Not open for further replies.

Share This Page