This code: Code: public void death(EntityDamageEvent e) { if (!(e.getEntity() instanceof Player)) return; Player p = (Player)e.getEntity(); if (p.getHealth() - e.getDamage() > 0) return; if (p.getHealth() <= 0) return; System.out.print(e.getCause().name()); for some reason prints out LAVA more than 1 time if you die in lava, and afaik it should not do that... any idea why?
I am the only player on the server and it fires so fast that ca. 10 players would have to die from lava at the same time...
Hmm ok, how did you register the event? I made a mistake once too with that it resulted in a lot of spam of the same things.
Line 90 calls a new playerkillthread for every entity damage event whether they have been killed or not? Just out of curiosity why did you not use the onPlayerDeath event and then just get the cause. I guess maybe fire and lava return the cause of death as fire but you could always check the combuster to determine what caused the fire.
Line 90 calls a new playerkillthread for every player that dies because of non-entity attacks. (lava, falling, osv..) I dont use the PlayerDeathEvent because I need the thing that kills the player, not the cause. The issue here is that the event gets called ca. 10 times if you die from lava, but only once if you die from say a spider.
But I thought the cause IS the damager? For an example; If I die from Lava, the cause for my death is Lava. Or, If I get damaged by Lava, the cause is Lava. EDIT: Or do you mean you need the one who placed the Lava?
Kinda, but if it is a zombie or a spider its ENTITY_ATTACK. A skeleton would be PROJECTILE... So that wont work
Ah I see. It may be a bug in bukkit. Can't you disable the check you've done with Lava and check all the other entities, then do a stand-alone check for the Lava damage cause? (Something like that)
I don't see the problem there. Making an if statement which separates them, because ENTITY_ATTACK you can get the direct entity, and if it's a projectile you can get the shooter which will give you the skeleton.
ye, I have that, but dying in lava keeps spamming ca. 10 events. that has been the problem since the start of this thread. Looking at the stuff that just came up from dying in lava: LAVA x6, FIRE x1, FIRE_TICK x1 How is it possible to die 7 times while beeing dead?
But since the start of the thread you use EntityDamageEvent, and not the suggested PlayerDeathEvent or EntityDeathEvent. Try that.
When jumping into lava: Code: Entity killer = e.getEntity().getLastDamageCause().getEntity(); Player killed = (Player)e.getEntity(); System.out.print(killer + " " + killed); this code ends up as Code: CraftPlayer{name=stelar7} CraftPlayer{name=stelar7} so I think you are mistaken somewhere...
stelar7 killed.getName(); and for killer try to use Code:java if(e.getEntity() instanceof HumanEntity) { HumanEntity kiler = (HumanEntity) e.getEntity().getLastDamageCause().getEntity();} Then use killer.getName(). And you should check if the entity who died is a player or else you might get ClassCastExceptions.
Lava isn't an entity. Code: EntityDamageEvent lastDamage = e.getEntity().getLastDamageCause(); if(lastDamage.getCause() == DamageCause.LAVA) System.out.println("it's freakin' lava!"); else if(lastDamage.getCause() == DamageCause.ENTITY_ATTACK) System.out.println("Oh hey entity + " lastDamage.getEntity()); else if(lastDamage.getCause() == DamageCause.PROJECTILE) { Projectile p = (Projectile)lastDamage.getEntity(); System.out.println("Someone shot you! it's " + p.getShooter()); } Something along those lines.
Basically what hes doing is looking up the damage cause and the entity who got damaged, in this case himself.