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

get player or human on ProjectileLaunchEvent

Comments in 'Plugin Development' started by MikkiMCPE, Aug 31, 2016.

  1. MikkiMCPE
    Offline

    MikkiMCPE Active Member

    Joined:
    May 16, 2015
    Posts:
    125
    Minecraft User:
    MikkiMC
    Are it is possible to get the shooting entity (the player who throw projectile)?

    So, the point is i want disable player to throw Egg or Snowball in creative mode.

    P.S. function getEntity() at ProjectileLaunchEvent it just call Projectile class not Entity or Player.
  2. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    The shooting Entity is basically $snowballEntity->shootingEntity
    MyNameIsTriXz likes this.
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Undefined variable $snowballEntity.

    You can use $shooter = $event->getEntity()->shootingEntity;
  4. MikkiMCPE
    Offline

    MikkiMCPE Active Member

    Joined:
    May 16, 2015
    Posts:
    125
    Minecraft User:
    MikkiMC
    there is no function name shootingEntity :( still not working
  5. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
  6. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    PHP:
    funtion ProjectileLaunchEvent(ProjectileLaunchEvent $event){
    if(
    $event->getEntity() instanceof Snowball || $event->getEntity() instanceof Egg){
    $shooter $event->getEntity()->shootingEntity;
    if(
    $shooter instanceof Player && $shooter->getGamemode() === 1$event->setCancelled();
    }
    }
    MikkiMCPE likes this.
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    It's a property, Projectile::$shootingEntity, not a method
    MikkiMCPE and CraftYourBukkit like this.

Share This Page

Advertisement