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

[New API] entities and players

Comments in 'Plugin Development' started by swagboy47, Jun 28, 2014.

  1. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    how do you get the name of the player that do an event like EntityMoveEvent?
  2. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    getName() ??
  3. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    no . i know how to get the name but not how to get the player if the player is doing an entity event
  4. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    So when a player for example moves, you want to get a message?
  5. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    EntityMoveEvent is not when a entity move . it's when a entity step on specific block .
  6. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    and i want to know how to get the player in an entity event
  7. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    let check it on the docs
  8. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    i already did :(
  9. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    they should add small sentences of code showing how to use it :(
  10. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    Oh, I thought it was if an entity moved. That's good to know.
  11. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    me too . before i looked at claymore and i found out
    Tuff likes this.
  12. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    Thanks for the tip!
  13. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    PHP:
    public function onMove(EntityMoveEvent $event){
       if(
    $event->getEntity() instanceof Player) {
       
    $playerobject $event->getEntity();
       
    $username $player->getName();
       }
    }
    Sorry for mistakes, this was written on my phone.
    PEMapModder and jython234 like this.
  14. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    No, it's when a entity moves :p
  15. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    That's what I thought :)
  16. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    EntityMoveEvent is called every tick for each player with speedX, speedY or speedZ not equal to 0.

    EntityMotionEvent is called only when a player's speedX, speedY or speedZ is changed.

    If you use PhpStorm, you will find out that warnings will still come out if you do it like this. So, store $event->getEntity() in a variable first to let your IDE know that $playerobject is the same one seen at $event->getEntity().
    PHP:
    public function onMove(EntiyMoveEvent $event){
        if((
    $playerobject $event->getEntity()) instanceof Player){
            
    $username $playerobject->getName();
        }
    }
    jython234 likes this.
  17. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    are they both the same ?
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Obviously not.
    EntityMoveEvent is when a player moves. This event is triggered whether the player's speed changes or not. It is called every tick for each entity unless the entity is not moving. "Move" includes rotating head.

    EntityMotionEvent is the event about the change of direction and/or speed of an entity.

Share This Page

Advertisement