Keep player alive?

Discussion in 'Plugin Development' started by Freelix2000, Jul 24, 2014.

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

    Freelix2000

    A long time ago, before I knew anything about plugin development, I remember playing on a server that had a PvP-based mini-game in which players would have weapons and abilities and, obviously, could kill each other. But I noticed that when a player died, it did not actually kill them but just teleported them to a respawn point, healed them, and restored their items. I have tried doing this by detecting if the victim's health minus the damage is less than 0 in entity damage event, but I don't think that will account for armor and armor enchantments. How can this be done?
     
  2. Offline

    Traks

    EntityDamageEvent#getFinalDamage() returns the damage change for all modifiers combined
     
  3. Offline

    daavko

    Freelix2000 Either you can do what the guy above me said, or listen to PlayerDeathEvent and do whatever you want to do with it...
     
  4. Offline

    EcMiner

    You could either force respawn a player. Or you could set the players' health to full in the PlayerDeathEvent, this will cause him to stay alive
     
  5. Offline

    ImDeJay

    Do like Traks said and check final damage if its gnna be below 0 then respawn them and give them items.
    Set the spawn point in a config and do player.teleport(location) and have an itemstack in the config and then do player.getinventory.clear then add your new itemstack to their inventory.
     
  6. Offline

    stormneo7

  7. Offline

    Necrodoom

    stormneo7 Theres plenty of working methods without resorting directly to NMS.
    Or spoonfeeding for that matter.
     
  8. Offline

    stormneo7

    Holy shit why are you such a washout about spoonfeeding?
    OP asked for a method for how to apply kit etc when the player dies. I gave the method and told him to apply the things after running that code.
    NMS is a hard topic, you can't just simply teach it through a Bukkit thread.

    We all know that if you don't know how to do something, we'll google it first.
    Eventually, we'll come by a thread which has the code and a good explanation and use it.

    Of course there are other ways but this is the method that I use.
    If you have any other suggestions, I'd LOVE to hear them.
    As of now, you're not even helping the OP poster learn the code.
    You're just crying that I'm spoon feeding code.
    Not a lot of other people have a big problem with that as in each code, there's usually an explanation that goes along with it so they DO LEARN.
    If you have a problem with the way I answer threads, cry to your mother.
    The way I see it, you're just trying to piss me off.
     
  9. Offline

    Necrodoom

    stormneo7 you post bad code then complain when people call you out on it.
    If you look above, you'd see that several other solutions, without NMS, are suggested, and the OP didn't even say he was having a problem with them.
    This means, you just pasted bad code out of nowhere then expect people to use your code, despite the fact that there's plenty of better solutions, like the code you posted at the thread about freezing.
    Again, if you can't bother even TRYING to post good code, don't bother posting.
     
    Saladoc likes this.
  10. Offline

    stormneo7

    Code:
    you post bad code then complain when people call you out on it.
    Example?

    Code:
    If you look above, you'd see that several other solutions, without NMS, are suggested, and the OP didn't even say he was having a problem with them.
    Try them out, tell me how it works out. The player would end up alive in a sideways (dead position) state.

    Code:
    This means, you just pasted bad code out of nowhere then expect people to use your code, despite the fact that there's plenty of better solutions, like the code you posted at the thread about freezing.
    Did I tell him to use it? It was simply a suggestion. Again, you're making up rumors to make yourself look good.

    Code:
    Again, if you can't bother even TRYING to post good code, don't bother posting.
    If you can't bother crying ABOUT my code, don't bother posting. All the posts you've created with me in the same thread were about the following...
    1. Spoon Feeding
    2. Bad Code
    3. Hard Method
    4. Plain Old Flaming
    5. Trying to Prove a point

    None of them were to actually help the original post.
    This thread is a perfect example.
    You instead flame on me instead of helping the OP figure it out.
    Doesn't that sound a bit cliche? What a sad life you must be living.
    Seems in real life, you don't like to be wrong, always on top.
    Then again, cocky people don't turn out well.
    They don't have friends and have to live a life on the web.
    Hope you know that.
     
  11. Offline

    Necrodoom

    stormneo7 ............
    I take it you never tried to cancel the damage first?

    Did the OP even said he had problem with previous suggestions?
    Did you explain why previous methods do not actually work, compared to your suggestion?
    Did you ever try to listen to others suggestions on how to fix your code, instead of complaining that they are trying to take you down? (Freeze thread, again is an example for this)

    You said you made a suggestion, yes? Then what's wrong with someone saying your suggestion is bad?

    Maybe, instead of insulting every each one that tries to help, you, and the OP, please try to listen.

    Plugin development is not a spoonfeeding competition. If you want me to explain why NMS is not a good choice to spoonfeed away as a solution, I'll help you.

    Also, helping means also directing OP to the correct solution, instead of the one that will cause him problems.

    But, whatever, you wouldn't even fix your code where you suggested the OP to 'freeze' by teleporting to the next location. Why would you listen now.
     
  12. Offline

    stormneo7

    Necrodoom
    This is literally what you're trying to say.
    OP question is similar to the Square of 4.
    Someone said it's 4x4.
    I said it's 4+4+4+4.
    You cry because my method's longer and there was a simpler way to do it.
    Must sound stupid doesn't it.


    Alright, lemme bitch at you now.
    Firstly, to cancel damage that did the finishing blow, you cannot do
    p.getHealth() - evt.getDamage() <= 0
    since that does not take armor into consideration. Therefore, you need to run a lot of armor bar checks and reduce the damage. As you said, that method is longer, harder, and stupid.


    He didn't reply. I simply gave another suggestion then start crying that my thing's harder, longer, and stupid.
    Next, the code will work. Idk why and how you want me to "Fix It". Why don't you give me the error because, for me, I can't see any!


    Not from you I'm not. You cry at useless reasons and say my code doesn't work while you cannot prove that it doesn't.
     
  13. Offline

    Necrodoom

    stormneo7 no, its because yours is version dependant and require updating every versions, and may break completely on an update, while cancelling the damage would work every time. If there's a solution in NMS and one not in NMS, then you should choose the non-NMS one.

    Also, did you look at the new entity damage javadocs?
    You don't need to check all the modifiers.
     
    Gater12 likes this.
  14. Offline

    Gater12

    stormneo7
    The rule of NMS is to use it when you absolutely have to. It breaks between versions because there might be code changes. Bukkit changed package names for NMS every version change to discourage people to use NMS.
     
  15. Offline

    Necrodoom

  16. Offline

    stormneo7

  17. Offline

    Gater12

    stormneo7
    Uses Reflection API which is slow.
     
  18. Offline

    EcMiner

    The server I work for used to use this for a while (Till I became coder on there and made it so it force respawns : p ) without major trouble, no death screens or whatever, but this was on an older build so it might cause it now, I'm not sure.
     
Thread Status:
Not open for further replies.

Share This Page