Hard to explain.

Discussion in 'Plugin Development' started by spurkle, Jul 26, 2014.

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

    spurkle

    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.
     
  2. Offline

    Niknea

    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.
     
    Dragonphase likes this.
  3. Offline

    spurkle

    Not really ;c
     
  4. Offline

    Niknea

  5. Offline

    Dragonphase

    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.
     
  6. Offline

    spurkle

    That might work. Maybe there are easier solutions for that?
     
  7. Offline

    Niknea

    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. ;)
     
  8. Offline

    xTigerRebornx

  9. Offline

    Niknea

    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.
     
Thread Status:
Not open for further replies.

Share This Page