Remove arrow after hit

Discussion in 'Plugin Development' started by Cjreek, Dec 26, 2012.

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

    Cjreek

    Hi,

    I want to remove arrows which hit a player so that they don't stick into the player.
    (because this reveals invisible players).

    I tried to use the EntityDamageByEntityEvent:

    Code:java
    1. if (event.getDamager() instanceof Projectile)
    2. {
    3. ((Projectile)event.getDamager()).remove();
    4. }


    but this is not working.
     
  2. Offline

    chasechocolate

    check if it is an instanceof Arrow, and then do ((Arrow)event.getDamager()).remove();
     
  3. Offline

    Cjreek

    This doesn't work either :-(
     
  4. Offline

    chasechocolate

    ProjectileHitEvent?
     
  5. Offline

    Cjreek

    I tried this as well a few minutes ago and just removed event.getEntity() on every ProjectileHitEvent but this didn't do anything.

    PS: I didn't forget to put @EventHandler before the event handler. I did some broadcasts at those events and they worked so the events themselves worked fine.
     
  6. Offline

    ImDeJay

    to me, this should work but ive been testing for like 20 minutes now and it doesnt work like it should

    but maybe someone can figure it out

    Code:
        @EventHandler
        public void blah(EntityDamageByEntityEvent event) {
       
       if(event.getEntity() instanceof Player){
       
       if(event.getDamager() instanceof Arrow){
       
       Arrow arrow = (Arrow) event.getDamager();
       
       arrow.remove();
       
       }
       }
        }
     
  7. Offline

    fireblast709

    try broadcasting the EntityTypes
    Code:java
    1. Bukkit.broadcastMessage(event.getEntity().getType().name());
    2. Bukkit.broadcastMessage(event.getDamager().getType().name());
     
  8. Offline

    Cjreek

    PLAYER
    ARROW

    But why should this change the behaviour of the code above?
     
  9. Offline

    fireblast709

    Cjreek then you know that the entities are what you expect ;3
     
  10. Offline

    Cjreek

    Ok^^ Trying this before posting here goes without saying for me ;)
    That's why I was a little bit confused.
     
  11. Offline

    Grave

    Sorry about digging up an old thread but I am also looking for a method of getting rid of arrows in a player body.
     
Thread Status:
Not open for further replies.

Share This Page