[SOLVED]: Teleporting Between Separate Worlds Not Working

Discussion in 'Plugin Development' started by Tenetri, Aug 8, 2012.

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

    Tenetri

    Greetings everyone, I've been working on a plugin, and I have enoutered countless errors, but this is the first one thats taking me more than 4 hours to try and solve. So I figure'd I would ask you guys/gals.

    So the plugin I am working on has Multiple Worlds. For the sake of Testing I created two worlds named 'world' and 'world2'

    Code:
    03:12:44 [WARNING] Task of 'TenetriPlugin' generated an exception
    java.lang.NullPointerException
            at org.bukkit.craftbukkit.entity.CraftPlayer.teleport(CraftPlayer.java:3
    53)
            at org.bukkit.craftbukkit.entity.CraftEntity.teleport(CraftEntity.java:1
    62)
            at me.Tenetri.TenetriPlugin.TenetriPlugin$1.run(TenetriPlugin.java:386)
            at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(C
    raftScheduler.java:126)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:525)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:451)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Code:
                for(Player OnlinePlayers : Bukkit.getOnlinePlayers())
                {
                    startingPlayerList.add(OnlinePlayers.getName());
                    OnlinePlayers.teleport(tpthepos); //**************
                }
    Line 386 is denoted with a //**************

    Code:
    tpthepos = new Location(theWorld,x,y,z,yaw,pitch);
    Okay, so the Teleport works if I load the correct World from the server.properties file and then restart the server. If I set "level-name=world2" then the line of code below DOESN'T work, but if I change the properties file to say "level-name=world", and try the same code below, it works Fine.

    Code:
    OnlinePlayers.teleport(Bukkit.getWorld("world").getSpawnLocation());
    So confused! Am I missing something obvious? Do I need to implement some multi world support? I tried doing GetChunk.LoadChuck().Load before teleporting, and it doesn't work. I've been working on this one error for many hours. I'm either really dumb and missing something obvious, or something...

    Thanks in Advance!!
     
  2. Offline

    stelar7

  3. Offline

    Tenetri

    Thankyou, this solved 50% of my issue! When I run my modified code, it now creates a whole new world, separate from the one that I want to load.

    Code:
    Bukkit.getServer().createWorld(new WorldCreator("test"));
    Location l = new Location(Bukkit.getWorld("test"),1,75,1);
    startingPlayerList.add(OnlinePlayers.getName());
    This works, but it doesn't teleport me to my world that I created seperately called 'test'. Its now teleporting me to a completely new world. I have a world folder in my server folder called 'test', but I don't get why its not teleporting me to it. Its just generating a whole new world.

    Is it possible to Load the world into memory, rather than trying to create a whole new one? or am I not doing something right?

    thanks again!
     
  4. Offline

    Anwarrex

    Tenetri
    Umm, jeez, I don't know. It's NOT about that you were generating a world at:
    Code:
    Bukkit.getServer().createWorld(new WorldCreator("test"));
    
    Remove that line and try again.
     
  5. Offline

    Tenetri

    Code:
            at org.bukkit.craftbukkit.entity.CraftPlayer.teleport(CraftPlayer.java:3
    53)
            at org.bukkit.craftbukkit.entity.CraftEntity.teleport(CraftEntity.java:1
    62)
            at me.Tenetri.TenetriPlugin.TenetriPlugin$1.run(TenetriPlugin.java:389)
            at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(C
    raftScheduler.java:126)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:525)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:451)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    The error is back. This is the origional code I had... without the world creator, I get an error.

    Line 389 is:
    Code:
    OnlinePlayers.teleport(l);
     
  6. Offline

    Anwarrex

  7. Offline

    Tenetri

    yepyep, best IDE ive ever used

    when I use the word 'test' for the mapname, it generates a completely new world, but it doesn't use the 'test' map that I have in the server directory. So weird ><

    I'm also still using 1.2.5, is this something that is fixxed in 1.3.1 and I should just try to recompile with the new one? I don't wana mess everything up again ><

    ty, NixillUmbreon from the IRC chat helped me fix it! <3

    Code:
    getServer().createWorld(new WorldCreator("worldBackup"));
    OnlinePlayers.teleport(new Location(getServer().getWorld("worldBackup"),1,75,1));
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
Thread Status:
Not open for further replies.

Share This Page