Solved A victim's killer is always null?

Discussion in 'Spigot Plugin Development' started by DarkPaladinUHC, Jun 11, 2017.

  1. All i am trying to do is get who killed a player. From what I under stand this should be a simple task.

    Code (Text):
    public static void on(PlayerDeathEvent e) {
    I understand that would be null if they died to the environment but it shouldn't if they die to a player, right?

    I have also tried setting this to be the highest priority to make sure nothing is interfering with it but it still comes back as null.
  2. Try making it the lowest priority instead. That way it's the first event to be fired.
    • Agree Agree x 1
  3. That worked, thanks! I thought highest priority would be fired first. Learn something new every day...
  4. The higher priority will get the final say in what to change in the event.

    A using LOWEST can cancel an event, but B using LOW or MEDIUM can then again uncancel/override what A is doing (it's getting a final say unless there is another plugin C using a higher priority). For this to be possible, we need A to listen and change first, so B can know what to change. So that's why.

    When first looking at it first, it makes sense that the higher priority, the more priority it should have in the listening order (like when enabling plugins). But that's not how it is, after reading on it, it becomes quickly clear and reasonable for it to be the other way (exactly because of overriding, etc...).

    Hope this cleared some stuff up!
    • Informative Informative x 1
  5. thanks for clearing that up!
  6. Problem solved? Please mark as Solved

    Code (Text):
    public static void on(PlayerDeathEvent e) {

       if(e.getEntity() instanceof Entity && (!null)){
  7. oops forgot to mark as solved