Hi. Sorry for using such thread title, i am just not sure how i could explain it without using too many text. The question: How can i 'connect' mob death to a player? Like. Let's say, i have a plugin that gives player different magic capabilities. Like, executing a command will fire an explosion using this: p.getWorld().createExplosion(p.getLocation(), 30.0F); And i have an entity death event, which does something for the entity killer. But if i use the following code, then the killer is an explosion, not a player. Is there an easy way of making the killer to be a player? Without doing complex stuff like saving player to a hashmap, and then check if player used a spell when entity died, etc? Sorry for my english, not my first language Thx.
spurkle Maybe this thread would help? EDIT: Now thinking about it, you can store the player in a HashMap, along with the location where the explosion landed (math will be needed for here), then get the location the player died, seeing if its near the explosion, and checking if the cause was an explosion.
spurkle If you're using a HashMap to store Players, be sure to properly dispose of them. Otherwise, you could store the player's name or UUID without any issues.
spurkle I doubt it, and if they are, by the time you figure it out, you could've made the way I told you work. All up to you.
spurkle Not using an actual explosion, only using a fake explosion and applying the damage and velocity yourself (along with logging who launched the spell as the attacker)
xTigerRebornx That may be a bit harder, as the player's distance from the explosion determines the amount of damage dealt to the player. So a lot of testing would be required for your method.