Solved Player.teleport() not working in a PlayerLoginEvent listener

Discussion in 'Plugin Development' started by dibujaron, Feb 14, 2013.

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


    @EventHandler(priority = EventPriority.MONITOR)
        public static void onPlayerLogin(PlayerLoginEvent event){
            if (JailedPlayer.isJailed(event.getPlayer())){
                JailedPlayer player = JailedPlayer.getJailedPlayerFromName(event.getPlayer().getName());
                if (player.state == 0){
                    player.previousLocation = event.getPlayer().getLocation();
                    player.state = 1;
    /*Extra notes: methods isJailed is proven to work. getJailedPlayerFromName is also proven to
    work. jailLocation is defined outside of this method but is also proven to exist. JailedPlayer
    object has variables name, previousLocation, and state. */
    Hey guys. I think the title of this thread explains what I need answered. For some reason, when this Event Handler is called, the line event.getPlayer().teleport(jailLocation); does nothing. I know that it gets called and works up to that point, and player.state is set to 1 like it is supposed to be, but for some reason the player is not teleported. I tried EventPriority.NORMAL and EventPriority.LOW as well. Any advice? Any help is appreciated, thanks very much!

    The console gave no errors.
  2. Offline


    Based on an initial observation... Ditch the static.

    Do you get any other errors?
  3. Offline


    LoginEvent is fired before the player is actually in.

    Try JoinEvent, although that might fire slightly before as well.

    Try scheduling it to go off a tick or two later.
  4. Offline


    Use playerjoinevent, login event is the process of getting onto the server and before the player really exists on the server.
  5. Offline


    Thanks guys!
Thread Status:
Not open for further replies.

Share This Page