Solved Projectile Hit Event

Discussion in 'Plugin Development' started by Pink__Slime, Apr 18, 2013.

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

    Pink__Slime

    I need an event that will give me both the player that threw the projectile and the player that gets hit.
    I was using ProjectileHitEvent but you can't get the player that gets hit and also using the following line, it grabs the actually projectile instead of the player.
    Code:java
    1. Entity e = event.getEntity();


    What I'm after is a way to get the player that threw the entity as well as the player the entity was hit by.

    Please only reply if you can help me. I've looked around and I couldn't find anything.
     
  2. Offline

    microgeek

    Wrong event. EntityDamageByEntityEvent
     
  3. Offline

    Pink__Slime

    I'm using that at the moment but it doesn't seem to work on projectiles... That's why I am looking for another event.

    If you could help me find a fix, that'd be great.
     
  4. Offline

    chasechocolate

    Yeah it does. if(event.getDamager() instanceof Projectile).
     
  5. Offline

    Pink__Slime

    chasechocolate
    Using this I can only get the player hit by the projectile. I can't actually get the player who threw the entity/shot the bow. That's what I'm looking for.
    Please forgive me if it's simple... I did look around.
     
  6. Offline

    chasechocolate

    Cast and then use projectile.getShooter().
     
  7. Offline

    Pink__Slime

    Works now thanks. :)
     
  8. Offline

    DennisLysenko

    I dont get what you mean? How is an if statement going to return a player name? im new to java sorry im more of a GameMaker guy. Here's my thread of the onProjectileHit()
    Code:
        @EventHandler
        public void onProjectileHit(EntityDamageByEntityEvent event) {
            Projectile projectile = (Projectile) event.getDamager();
            Player player = (Player) projectile.getShooter();
            player.sendMessage("You Hit " + event.getDamager() + "!");
        }
    this is what i have so far. but i want to make it say that the guy who got shot to get a message saying you got shot by the shooter. PLEASE HELP ASAP! I dont go on this page alot so please email me and post it here to help. [email protected]
     
  9. Offline

    LightcraftLP

    Please write the FULL code ! :( I need help too.... so how I can check if the Projectile hit the head of a player?
     
Thread Status:
Not open for further replies.

Share This Page