Solved Custom Death Messages on Custom Kill Types

Discussion in 'Plugin Development' started by mine2012craft, Jul 21, 2017.

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

    mine2012craft

    Hello,

    So basically, I have a method of killing that is unique and not part of any of the DamageCauses.

    We'll say that a custom fireball projectile (Not the Ghast Projectile) is the method of killing I do. How would I set it so I have a custom death message for it?

    ex. "<Victim> came in contact with <Killer>'s ball of flame"
     
  2. Offline

    Zombie_Striker

    @mine2012craft
    1. Create an Hashmap. Keys will be player's UUId and the values will be custom fireballs.
    2. On EntityDamageByEntityEvent
    3. If the damage is the custom fireball, and the victim is a player
    4. If the player will die from this attack
    5. Add the player and the fireball to the hashmap.
    6. On PlayerDeathEvent
    7. If the player was in the hashmap.
    8. Set the custom death message and remove the player from the hashmap.
     
  3. Offline

    mine2012craft


    The custom fireballs are not an object. They are from BukkitRunnables that create an animating ball of flame particles that deal damage on impact with a LivingEntity.
     
  4. Offline

    Zombie_Striker

    @mine2012craft
    Then don't do steps #2 though #5. Instead, inside the runnable, if a player is damaged and will die, add them to the hashmap.
     
  5. Offline

    mine2012craft

    How would I check if the player will die in the first place?
     
  6. Offline

    Zombie_Striker

    @mine2012craft
    Check if the player's current health, minus the amount you are going to damage the player, is less than or equal to 0.
     
  7. Offline

    mine2012craft

    Ok, so I made the method, works great. The problem is that say someone has iron armor on, and the fireball's core damage is 7. The iron armor guy will take 4 damage, but the code will minus a hardcore 7 from the health without counting the AV, and if it equals 0, then it'll change the death message. How would I fix something like this?
     
  8. Offline

    Zombie_Striker

  9. Offline

    mine2012craft

Thread Status:
Not open for further replies.

Share This Page