1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Player keeps invisible, after teleporting on PlayerDeathEvent

Discussion in 'Development' started by Akuroma, Jun 5, 2019.

  1. Akuroma

    Akuroma Silverfish

    Messages:
    20
    GitHub:
    Akuroma
    Hey there. I'm coding my own FFA-plugin.
    The problem: If I heal, feed and teleport the player on PlayerDeathEvent he respawns, but keeps invisible to other players. Months ago this method worked well. Is there any new way, which I could use? :)
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Why are you trying to do all that?
     
  3. Akuroma

    Akuroma Silverfish

    Messages:
    20
    GitHub:
    Akuroma
    I used this method about a year ago to respawn players instantly after beeing killed, so that they don't need to click respawn. But now this method doesn't work anymore. :(
     
  4. A354-PH

    A354-PH Baby Zombie

    Messages:
    186
    GitHub:
    Kizu
    The code/method may have set them to Gamemode 3(Spectator)
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That method shouldn't have been working at all, it was just a fluke. ¯\_(ツ)_/¯
    I don't think there's a clean way to do this yet.

    You could do something like cancelling the RespawnPacket during DataPacketSendEvent and calling Player->respawn() (which um, is a protected method in api3, but maybe reflection hack it?).
    Or better... just cancel the EntityDeathEvent assuming you don't have any Player->kill() calls in your plugin. Listen to EntityDeathEvent on the HIGHEST priority and cancel the event if the final damage is greater than player's health.

    You'll still need a way to respawn the player with emptied inventories, emptied crafting grid, xp, health, saturation, respawn position etc for which I think you'll need to gain access to Player->respawn() using reflection hacks.
     
  6. SleepSpace9

    SleepSpace9 Slime

    Messages:
    78
    GitHub:
    sleepspace9
    You probably meant to cancel EntityDamageEvent because EntityDeathEvent is not cancellable.
     
  7. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Yep, autocorrect got me good.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.