Code: @EventHandler public void onEntityExplode(EntityExplodeEvent event) { Location explosionLocation = event.getLocation(); for(Player p : Bukkit.getOnlinePlayers()) { Location playerLocation = p.getLocation(); if(explosionLocation.distance(playerLocation) <= 5) { //Player p is near the explosion. } else { //Player p is not near the explosion. } } }
I would think it would be more effecient to loop through getNearbyEntities() for the location of the explosion, rather than loop through every player that's online and check their distance.
getNearbyEntities requires an Entity object though. So unless you get the TNT/Creeper/Whatever entity, you're out of luck.
Well, likely he'll be listening to the EntityExplodeEvent, in which case he would have an entity to work with.
This is a stupid idea, but why not try to cast Entity to the explosion? I have 99% doubt that this idea will fail.