Solved Teleport dont work after death in PlayerJoinEvent

Discussion in 'Plugin Development' started by re4ly, Oct 19, 2013.

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


        @EventHandler(priority = EventPriority.MONITOR)
        public void joinevent(PlayerJoinEvent e) {
            final Player p = e.getPlayer();
            if (plugin.arena.containsKey(p.getName())) {
    This code works normally. But if a player dies, hit the button "Title-screen" and join later he will not teleport.
  2. Offline


    You'll need to use respawn event too, because when they log back in they will need to respawn.
    Something like this: (Untested)
    1. @EventHandler(priority = EventPriority.MONITOR)
    2. public void respawnevent(PlayerRespawnEvent e) {
    3. final Player p = e.getPlayer();
    4. if (plugin.arena.containsKey(p.getName())) {
    5. p.teleport(loc);
    6. }
    7. }
  3. Offline


    I use the respawn event to respawn players in my arena

    1. @EventHandler(priority = EventPriority.MONITOR)
    2. public void ArenaRespawn(PlayerRespawnEvent e) {
    3. Player p = (Player) e.getPlayer();
    5. if (plugin.spieler.containsKey(p.getName())) {
    6. e.setRespawnLocation(plugin.regions.get(plugin.playerregion.get(p.getName())).getSpawn());
    7. plugin.spieler.get(p.getName()).prepare(p);
    8. plugin.modes.get(plugin.regionmode.get(plugin.playerregion.get(p.getName()))).prepare(p);
    9. }
    10. }

    help please

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 4, 2016
  4. Offline


    What you could try doing is also teleport the player on PlayerQuitEvent if the player is dead.
  5. Offline


    Just check if they are dead before teleporting them, and if they are, respawn them.

    EDIT: Thinking about it, I don't know if you can force a respawn. Just listen for PlayerRespawnEvent and teleport them then.
    re4ly likes this.
  6. Offline


    RealDope You're real dope RealDope.
    RealDope likes this.
Thread Status:
Not open for further replies.

Share This Page