Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Remove one item on interact

Comments in 'Plugin Development' started by jjmc, Dec 5, 2015.

  1. jjmc
    Offline

    jjmc New Member

    Joined:
    Oct 18, 2015
    Posts:
    41
    Hi,
    How can I remove the item on PlayerInteractEvent, so you can only use it one time?
    But only one item, if the player has two, he should have one after this.
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
  3. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Look at the sourcecode of economySell.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    /** @type Player $player */
    $inv $player->getInventory();
    $item $inv->getItemInHand();
    $item->count--;
    $inv->setItemInHand($item);
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I needed the same thing like you, I just did: $item = new Item(id, damage, amount); then $player->getInventory()->remove($item); and then right after it $player->getInventory()->addItem($item)

Share This Page

Advertisement