Help with inventories?

Discussion in 'Plugin Development' started by LazyLemons, Mar 3, 2013.

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

    LazyLemons

    So, I'm creating custom inventories like so:
    Code:
        final Inventory inv = Bukkit.getServer().createInventory(e, 9, ChatColor.DARK_GRAY + "Drug Dealer"); 
    Then in my listener I have the following code blocks:
    Code:
     int weedID = e.getInventory().first(Material.INK_SACK);
    Bukkit.getServer().broadcastMessage("" + weedID); 
    ItemStack weed = e.getInventory().getItem(weedID);
    weed.setAmount(weed.getAmount() - 1); 
    The broadcast message is always returning the cactus green that I have in the custom inventory, instead of the player's inventory. How would I check if the player's inventory has the item, not the custom inventory?
     
  2. Offline

    minoneer

    You can access the players inventory through player.getInventory(). Then you can do the same operations as you did on the other inventory
     
    LazyLemons likes this.
  3. Offline

    LazyLemons

    Alright, I used:
    Code:
     if (e.getWhoClicked().getInventory().contains(Material.INK_SACK)) 
    and it worked. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page