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

[New API] How do you tell if an entity is a player? [SOLVED]

Comments in 'Plugin Development' started by LDX, Jul 16, 2014.

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

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,429
    Plugins:
    14
    In the old API, I used this:

    PHP:
    if($this->api->player->get($data["entity"]->name) instanceof Player) {
    What would be the new API equivalent?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    In new API, $entity can be an instance of Player.
  3. Dutok
    Offline

    Dutok Notable Member Plugin Developer

    Joined:
    Jun 20, 2014
    Posts:
    371
    Plugins:
    3
    Minecraft User:
    Dutok
    Something like this, probably:
    PHP:
    if($entity instanceof Player){
  4. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,429
    Plugins:
    14
    So an entity can be an instance of multiple things??
  5. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,429
    Plugins:
    14
    Confirmed. Thanks, guys! I found this in line 408 of Entity.php.

    PHP:
    if($this->dead === true and !($this instanceof Player)){
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    class Player extends Human extends Living extends Entity
    LDX likes this.
Thread Status:
Not open for further replies.

Share This Page

Advertisement