1.8.8 Teleporting to 'world' and not specified world.

Discussion in 'Spigot Plugin Development' started by Embrasure, Jan 21, 2020.

  1. Hi,

    Sometimes, when I call Player#teleport(), it teleports the user to the spawnpoint in 'world', and not the specified location.

    There are no errors in console.

    This sometimes happens in a PlayerJoinEvent, where the console prints:
    Code (Text):
    logged in with entity id 3922 at ([SkyHub]0.4726654769699049, 50.0, 0.4810457954751853)
    My code:
    Code (Java):
    World w = Bukkit.getWorld(LocalDataHandler.getInstance().getConfig().getString("lobby.world_name"));
            double x = Double.parseDouble(String.valueOf(LocalDataHandler.getInstance().getConfig().getDouble("lobby.x")));
            double y = Double.parseDouble(String.valueOf(LocalDataHandler.getInstance().getConfig().getDouble("lobby.y")));
            double z = Double.parseDouble(String.valueOf(LocalDataHandler.getInstance().getConfig().getDouble("lobby.z")));
            float yaw = (float) Float.parseFloat(String.valueOf(LocalDataHandler.getInstance().getConfig().getDouble("lobby.yaw")));
            float pitch = (float) Float.parseFloat(String.valueOf(LocalDataHandler.getInstance().getConfig().getDouble("lobby.pitch")));
            e.getPlayer().teleport(new Location(w, x, y, z, yaw, pitch));
    This also sometimes happens in a joinGame() method. (I've checked if the location is null.)
    Code (Java):
    p.teleport(new Location(Bukkit.getWorld(arena.getWaitingLobby().getWorld().getUID()), arena.getWaitingLobby().getX(), arena.getWaitingLobby().getY(), arena.getWaitingLobby().getZ(), arena.getWaitingLobby().getYaw(), arena.getWaitingLobby().getPitch()));
    Any help would be appreciated.
  2. On the player join event, make a runnable that is executed a bit later. Since it’s a hub I guess that every time a player joins they are teleported to spawn point so if you teleport them a bit after that you should be fine
  3. It’s already in a 2 tick runnable.
  4. I had the same issue, surprisingly it was happening with 1.8 clients only, when I updated my server out of 1.8 it was still happening for those who used 1.8 (with protocol hack), but not for other version players, so it looks like a 1.8 bug
  5. Increase it to 20. 2 is too low
  6. How would I work around the joinGame() method issue?
  7. ^^^^^Join event teleport a bit more after or show full class for help
  8. joinGame() isn't my PlayerJoinEvent
  9. Then show the full joinGame() method
    Also what object does arena.getWaitingLobby().getWorld() return? A world? Why use Bukkit.getWorld()?
  10. Code (Java):
    for (Arena a : Main.arenas) {
                if ([B]!a.isActive()[/B]) {
                    if (!a.isDoubles()) {
    Can I ask why are you using a non-active arena as an usable arena? Also why don't you put both of your if on the same line?

    Code (Java):
    It seems like getWaitingLobby() returns a location so why not just use it like that?
  11. 'active' returns true if a game has begun.

    That's the problem - when I use that to teleport, it teleports me to 'world' instead of the specified world in the waiting lobby location.
  12. Use system.out.println(finalArena.getWaitingLobby().toString()); to see the actual world of that location