getItemID

Discussion in 'Plugin Development' started by Moon_werewolf, Jan 15, 2011.

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

    Moon_werewolf

    i making a function in my plugin that going to count all item of one type. but i just get error messages then i try :/

    here is the item count function

    Code:
    public int itemCount(Player player, int itemType)
        {
            int totalAmount = 0;
            ItemStack inventory[] = player.getInventory().getContents();
    
            for(int i=0; i<inventory.length; i++)
            {
                if(inventory[i] != null && inventory[i].getTypeID() == itemType)
                {
                    totalAmount += inventory[i].getAmount();
                }
            }
    
            return totalAmount;
        }
    and here is the error messages i get (repeated 35 times (i think))
    Any idea how to fix it?
     
  2. Offline

    Nsuidara

    PHP:
        public int itemCount(Player playerint itemType)

        {
            
    int totalAmount 0;
            
    ItemStack inventory[] = player.getInventory().getContents();

            for(
    int i=0i<inventory.lengthi++)
            {
                if(
    inventory[i] != null && inventory[i].getTypeId() == itemType)
                {
                    
    totalAmount += inventory[i].getAmount();
                }
            }

            return 
    totalAmount;
        }
    Test :
    Run : Success :]

    Console : give Nsuidara 1 33,
    itemCount(player,1).
    and Chat insert 33 :] THX :]
     
  3. Offline

    Moon_werewolf

    i just get this then i try :(

     
  4. Offline

    axel3200

    Looks like you don't have the most recent release of Bukkit, you need to get that for it to work.
     
  5. Offline

    Moon_werewolf

    Great the new version broke my plugin.yml -.-
    Code:
    name: mGold
    main: com.moon_werewolf.bukkit.mGold.mGold
    version: 1
    for some reason i have never seen so annoying file

     
  6. Offline

    axel3200

  7. Offline

    Moon_werewolf

Thread Status:
Not open for further replies.

Share This Page