Solved Delete specific Item from Player

Discussion in 'Plugin Development' started by AGreenPig, Jun 17, 2019.

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

    AGreenPig

    Hi!
    So I made an Item that you can't get as a survival player(an enchanted Clock with a name). Now I have everything I wan't for my plug in done, just the deleting part doesn't work. The Item simply doesn't go away. Have I missed a Funktion or have Ijust done something wrong?
    I wan't to be able to only delete a specific amount of items and just the special one, not every clock in a players inventory. This is my code so far:
    Code:
    ItemStack talonCoin= new ItemStack(Material.CLOCK);
            ItemMeta itemMeta=talonCoin.getItemMeta();
          
            itemMeta.setDisplayName(ChatColor.AQUA+"Talon");
            itemMeta.addEnchant(Enchantment.DURABILITY, 1, true);
            talonCoin.setAmount(amount);
          
          
            talonCoin.setItemMeta(itemMeta);
    ...
    
    Inventory inv=player.getInventory();
                    inv.remove(talonCoin);
    PS: I initialised the int amount of coure, but I thought I'll only post the relevant code...
     
    Last edited by a moderator: Jun 17, 2019
  2. Offline

    Tango_

    @AGreenPig

    Might have to loop through the ItemStack[] of inventory contents and then check if the item .isSimilar(talonCoin) and then try setting the stack size to 0. I think the .remove(ItemStack) only works when the stack size is identical.
     
  3. Offline

    AGreenPig

    oh..i just had to chnage it from remove to removeItem...*FacePalm* :)
     
  4. Offline

    Tango_

    Make sure you set the thread to solved :)
     
  5. Offline

    AGreenPig

    @Tango_
    :eek:Uhm...How? ... I'm New sorry :rolleyes:

    Edit: OK I did IT :p:rolleyes:
     
Thread Status:
Not open for further replies.

Share This Page