[close] scanning for an item in a player's inventory!?!

Discussion in 'Programming' started by Soulcraft245, Nov 19, 2017.

  1. I trying using
    Code (Text):
    Code (Text):
    p.getInventory().containsAtLeast(a, 1)
    idk how to really use containsAtLeast. tho I know you have to pass into two arguments, but I don't know what the second argument is looking. I do know I need to pass in an int.

    this is how I have it setup

    Code (Text):
    Material i = e.getItem().getItemStack().getType();
                    ItemStack a = e.getItem().getItemStack();
                    p.sendMessage(ChatColor.AQUA + i.toString());
                    if(p.getInventory().contains(i) && ! p.getInventory().containsAtLeast(a, 1)){
                        p.sendMessage(ChatColor.AQUA + "flight enabled");
                        p.sendMessage(ChatColor.AQUA + "flight disable");
    is there a better way to look through the player's whole inventory to find an item you want to look for??
    • Like Like x 1
    • Useful Useful x 1
  2. so I think I got this down now. this is how I set it up.
    Code (Text):
    for (int i =0; i < p.getInventory().getContents().length; i++) {
                        if (!p.getInventory().contains(i) && p.getInventory().contains(Material.SKULL_ITEM)) {
                            p.sendMessage("" + i);
    • Useful Useful x 1