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

Event for Player touches other Player - Even in Cmode?

Comments in 'Plugin Development' started by DaveCozens, May 1, 2015.

  1. DaveCozens
    Offline

    DaveCozens New Member

    Joined:
    Feb 4, 2015
    Posts:
    20
    Hey folks,
    I'm writing a tag plugin (Tag! you're it!) which is riding on the EntityDamageByEntityEvent event

    i.e.
    public function onPlayerTag(EntityDamageByEntityEvent $event){
    // do some stuff
    }

    but this doesn't work if the target is in Cmode as the event is cancelled before I get to listen to it.

    Is there some other way of detecting this player a touches player b events?

    Thanks,
    D
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    EntityDamageByEntityEvent is not an event that you should put in type hint. Look into PocketMine source, if there is public static $handlerList you can listen to that event, if no, you either need to use its superclasses instead or it isn't an event that is ever fired.
  3. DaveCozens
    Offline

    DaveCozens New Member

    Joined:
    Feb 4, 2015
    Posts:
    20
    It's firing for me. The listener is working, however, it's cancelled for players in cmode before I ever see it (in player.php)
    if($this->isCreative()
    and $source->getCause() !== EntityDamageEvent::CAUSE_MAGIC
    and $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE
    and $source->getCause() !== EntityDamageEvent::CAUSE_VOID
    ){
    $source->setCancelled();
    } else { /**more stuff

    so I could do with something more useful. Is there not an event we can use for Player A touches Player b?

    I guess I could do it onMove but that doesn't seem ideal...
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You can. If you have @ignoreCancelled false (as default), it will still listen to the event.
    But anyway you mustn't listen to EntityDamageEvent or other bugs will happen.
  5. DaveCozens
    Offline

    DaveCozens New Member

    Joined:
    Feb 4, 2015
    Posts:
    20
    Awesome. Where would I put @ignoreCancelled ?

    Apologies, been writing pocketmine plugins for about 24 hours...
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You don't need to. It is default.

Share This Page

Advertisement