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

Get The Thrower of a Snowball

Comments in 'Plugin Development' started by Samueljh1H8sLag, Jun 21, 2015.

  1. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Hi I want to know how you can get the thrower of a snowball in a ProjectileHitEvent?

    I would do something like put an array with that player's name to the entities ID but i cant seem to get the player in the ProjectileLaunchEvent or anything like that.

    Any Suggestions? Thanks.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $projectile->shootingEntity
    Inta likes this.
  3. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Oh yea lol i saw that before but i forgot xD
  4. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Ok can you show me how to do this?

    I use an onDamage event rather than a death event.

    I do this:

    PHP:
    if(($pldp->getHealth() - $sd->getFinalDamage()) < || $sd->getCause() === EntityDamageEvent::CAUSE_VOID){

    $sd->setCancelled();

    $pldp->setHealth(20);
    So i want to know how i can make it detect when someone is "pushed" into the void by someone throwing a snowball at them. Do you know how? :)
  5. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Here is some of the function to get the reason:

    PHP:
    if($pldp instanceof Player) {

    if (
    $sd instanceof EntityDamageByEntityEvent) {

    var_dump($sd->getDamager());

    if (
    $sd->getDamager() instanceof Player) {

    $deathMessage "§8§l[§4SC§8] §6Sky§4Wars§8>§r§6 " $pldp->getName() . " §4was killed by §6" $sd->getDamager()->getName() . "§4!\n§6" $this->P1 " §4Players Remain!";

    LeaderBoardSystem::getInstance()->addOther($sd->getDamager()->getName(), "kills");

    }

    else {

    //TODO: Get tnt placer, shooter etc.

    $deathMessage "§8§l[§4SC§8] §6Sky§4Wars§8>§r§6 " $pldp->getName() . " §4has Died!\n§6" $this->P1 " §4Players Remain!";

    }
    } else {

    $deathMessage "§8§l[§4SC§8] §6Sky§4Wars§8>§r§6 " $pldp->getName() . " §4has Died!\n§6" $this->P1 " §4Players Remain!";

    }

    LeaderBoardSystem::getInstance()->addOther($pldp->getName(), "deaths");

    foreach (
    $this->players as $dpa) {

    $dpa->sendMessage($deathMessage);

    }
    }
  6. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_

Share This Page

Advertisement