Auto-Respawn

Discussion in 'Plugin Development' started by naorpeled, Mar 17, 2013.

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

    RingOfStorms

    Why???

    Why is this so hard to just do it on the death event like I put? If that doesn't work then delay it by like 3 ticks or whatever but that is literally 1 extra line of code to what I have.

    No reason to do any looping and crap that will just consume cpu, honestly I'm done trying to help this topic since the answer has been posted _._
     
    Bone008 likes this.
  2. RingOfStorms Oh, Sorry. I never saw your code. Should really read all of a thread next time ._.
     
  3. Offline

    567legodude

    RingOfStorms When I use Packet205ClientCommand, it says Packet205ClientCommand can not be resolved to a type. Do you know an updated method of achieving this?
     
  4. Offline

    Skionz

    Create a new thread... Or even better, read through the protocol http://wiki.vg/Protocol
     
  5. Offline

    Mr. Mister Man

    Spigot has a respawn API. If you're using that, I believe you can do player.respawn();
     
  6. Offline

    TheCodingCat

    ummm HelGod I dont know what version of bukkit you using but im pretty sure Packet250CleintCommand was replaced with PacketPlayInClientCommand . This is how i do it. But I DO recommend to listen for damage event instead and checking if the damage s higher than the damaged entities(players) health.
    Code:java
    1. ((CraftPlayer)event.getPlayer()).getHandle().playerConnection.a(new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN));
    ]
     
  7. Offline

    567legodude

    TheCodingCat So would I use that on a PlayerDeathEvent or some other method of checking if they died.
     
  8. Offline

    TheCodingCat

  9. Offline

    567legodude

    TheCodingCat It doesn't seem to work. This is what I have:
    Code:java
    1. @EventHandler
    2. public void onDeath(PlayerDeathEvent event) {
    3. ((CraftPlayer)event.getEntity()).getHandle().playerConnection.a(new PacketPlayInClientCommand(EnumClientCommand.PERFORM_RESPAWN));
    4. }
     
  10. Offline

    TheCodingCat

    put it in a scheduler/Bukkit Runnable because it takes time for the bukkit death event to send the respawn screen.
     
  11. Offline

    567legodude

  12. Offline

    TheCodingCat

    i think about a tick or so would be good :) if not then make it a little higher
     
  13. Offline

    Crud41

    You guys are doing this all wrong. The idea is that the player goes into a "death" screen upon their HP hitting zero. So use a entitiy damage event handlder and check if the entity is an instance of player. Check if damage is greater or equal to the HP of the player. If it is, cancel the damage, set their HP to 20, and teleport them to spawn.

    You can't cancel a death screen. It's like teleporting a dead player to you, they don't exist in the game until they've respawned, meaning you can't teleport them.
    567legodude TheCodingCat Mr. Mister Man Skionz XlegitXcrazymanX RingOfStorms
     
    JaySN likes this.
  14. Offline

    TheCodingCat

    I agreee Crud41 I like using the entity damage event too BUT this works for me and for a lot of other people as well and although its probably not the best way to go it still is fine
     
  15. Offline

    Crud41

    Just realized how old this thread is.

    Since this is probably going to be locked, I will say this.

    "Thy shall not resurrect threads over 3 months old."
     
  16. Offline

    567legodude

    That was going to be my first approach. I guess I will give that a try.
     
  17. Offline

    timtower Administrator Administrator Moderator

    Locking this necro bump.
     
Thread Status:
Not open for further replies.

Share This Page