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

Get item data

Comments in 'Plugin Development' started by BSHRMG, Aug 18, 2016.

  1. BSHRMG
    Offline

    BSHRMG New Member

    Joined:
    Mar 15, 2016
    Posts:
    21
    Hello I want to know how to the the item data for example
    ID = 351
    Data = 11

    PHP:
    public function onSelect(PlayerInteractEvent $event){
    $player $event->getPlayer();
    $item $event->getItem();
    if(
    $item->getId() == ??){
    $player->sendMessage("labas rytas");
    }
    }
    I don't know how to do it xD
  2. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    $item->getDamage();
    BSHRMG likes this.
  3. BSHRMG
    Offline

    BSHRMG New Member

    Joined:
    Mar 15, 2016
    Posts:
    21
    For example?
    PHP:
    public function onSelect(PlayerInteractEvent $event){
    $player $event->getPlayer();
    $green Item::get(351);
    if(
    $green->getDamage() == 11){
    $player->sendMessage("labas rytas");
    }
    }
  4. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    No, $green's damage will always be 0 since you created it with damage 0
    BSHRMG likes this.
  5. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    $item->getId() returns the item ID. $item->getDamage() returns the item damage.


    PHP:
    public function onSelect(PlayerInteractEvent $event){
    $player $event->getPlayer();
    $item $event->getItem();
    if(
    $item->getId() === 351 and $item->getDamage() === 11){
    $player->sendMessage("labas rytas");
    }
    }
    TutoGamerWalid, BSHRMG and applqpak like this.
  6. BSHRMG
    Offline

    BSHRMG New Member

    Joined:
    Mar 15, 2016
    Posts:
    21
    Thank you :D

Share This Page

Advertisement