Why is this not working?

Discussion in 'Plugin Development' started by the_merciless, Feb 20, 2013.

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


    I have used this exact code in many other plugins i made, yet for some reason its not working for me now....

        public void onrespawn(PlayerRespawnEvent e ){
            Bukkit.broadcastMessage("This is the respawn event!");
            Player p = e.getPlayer();
            String w = plugin.getConfig().getString("Lobby.world");
            String x = plugin.getConfig().getString("Lobby.x");
            String y = plugin.getConfig().getString("Lobby.y");
            String z = plugin.getConfig().getString("Lobby.z");
            String yaw = plugin.getConfig().getString("Lobby.yaw");
            String pitch = plugin.getConfig().getString("Lobby.pitch");
            Bukkit.broadcastMessage("World: " + w + " x: " + x + " y: " + y + " z: "+ z);
            double xd = Double.parseDouble(x);
            double yd = Double.parseDouble(y);
            double zd = Double.parseDouble(z);
            float yawd = (float) Double.parseDouble(yaw);
            float pitchd = (float) Double.parseDouble(pitch);
            Bukkit.broadcastMessage("Converted Strings");
            Location lobby = new Location(Bukkit.getServer().getWorld(w), xd, yd, zd);
            Bukkit.broadcastMessage("Set Location");
            Bukkit.broadcastMessage("Commencing tp");
            Bukkit.broadcastMessage("teleport successful.");
    All the messages are broadcast, world/co-ords are showing up correct but i still get tp'ed to the spawn location. Been through all other plugins and changed all spawn settings and it still wont tp me to the lobby. Any ideas?
  2. Offline

    ZeusAllMighty11 Retired Staff

    You can't TP instantly on respawn - it fires before the player is actually respawned.

    Put in like a 3 tick delay with a scheduler
  3. Offline


    Player isn't respawned when that event is triggered.
    You must use event.setRespawnLocation() or trigger the code later, 1 tick at least.
  4. Offline


    Thanks, I eventually figured it out myself though. Go me!
Thread Status:
Not open for further replies.

Share This Page