1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Remove Item with custom name

Discussion in 'Help' started by _XHazardX_, Oct 15, 2017.

  1. _XHazardX_

    _XHazardX_ Spider Jockey

    Messages:
    33
    GitHub:
    XHazardX420
    Hello, I need help with something, how can I remove an item from a players inventory that has a custom name?
     
  2. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    If you want it to be when a player interacts with the item then do ~
    PHP:
    public function onHeld(PlayerInteractEvent $e) {
        
    $player $e->getPlayer();
        
    $hand $player->getInventory()->getItemInHand();
     
        if(
    $hand->getCustomName() === "CUSTOM NAME") {
            
    $player->getInventory()->remove($hand);
    else ~
    PHP:
    $item $player->getInventory()->getCustomName() === "CUSTOM NAME");
    $player->getInventory()->remove($item);        
     
    Last edited: Oct 15, 2017
    _XHazardX_ likes this.
  3. _XHazardX_

    _XHazardX_ Spider Jockey

    Messages:
    33
    GitHub:
    XHazardX420
    Thanks for the help!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.