Stupid damage(0) is able to kill entities

Discussion in 'Plugin Development' started by black_ixx, Jan 9, 2013.

Thread Status:
Not open for further replies.
  1. Hey,
    well currently I'm working at my warplugin which contains grenades, flashbangs etc.
    For example flashbangs create a explosion WITHOUT DAMAGING ANYONE but with adding a potion effect to players. Everything works fine. Almost.
    Everytime when I just want to cancel a damageevent without removing the "cool" damage animation I've used event.setDamage(0). But exactly this code is damages. It takes one live because is has to take at lost one. Even when a player has health 20 multiple explosions with damage 0 are able to kill him. But why?? I think nobody wants to damage somebody with using damage(0). This problem appears often.... I've found a way to fix it, but it's takes years. Are you able to fix this? Or is this needed/important?
     
  2. Offline

    TnT

    Moved to plugin development.

    Please use this forum or IRC for discussion about why the API is how it is. If you find a bug, leaky is the place to post it.
     
  3. Offline

    CubixCoders

    Try player.damage(0);
     
  4. Offline

    Muxon

    Maybe after the player gets the damage set his health back to 20, indeed not the best solution i think but should work
     
  5. Offline

    evilmidget38

    If you trigger the player's death, setting their health back to 20 doesn't sound like it's going to work.
     
  6. Offline

    CubixCoders

    Maybe set their health to what it was before you damaged them.
     
  7. Currently my code looks like this:

    The event starts.
    The lives of the players are stored in a hashmap.
    When a player was damaged, the plugin sets the event damage to 0 and takes the damage amount at the hashmap.
    At the end of the code the players health are set to the amount at the hashmap.
    If the damage is 0 the event is canceled.

    The thing is that I just don't understand why it damages a player. Probably nobody wants this and if somebody wants to damage, then he can just set it to 1 or more. Well maybe it has a cause... but what cause?
    A change would probably help many developers I think.
     
  8. Offline

    Lolmewn

    event.setCancelled, but play the animation on the player anyway?
     
  9. You are BukkitDev Staff? Congrats :D

    Well but how to play animations like this?
     
  10. Offline

    fireblast709

    black_ixx assuming you want the hurt animation
    Code:java
    1. player.playEffect(EntityEffect.HURT);
     
    black_ixx likes this.
  11. Thank you I will try this out :D
     
Thread Status:
Not open for further replies.

Share This Page