Need TP Help

Discussion in 'Plugin Development' started by chenr1, Jun 15, 2012.

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

    chenr1

    Hey guys, i need some quick help, So what I need is when the player dies or respawns I want them to be TP'd to a specefic X, Y, Z cordinate. I've tried p.teleport(location) and all of that but I cant seme to get anything to work. Any help?
     
  2. World world;
    double x,y,z
    player.teleport(new Location(world,x,y,z));
     
  3. Offline

    chenr1

    Thanks, Do I replace x, y, z with the cordiantes? And thanks again.

    Ok i think i fixed it. Is it ok that i had to initialize world to null?

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

    dxwarlock

    yes, Just replace x,y,z with the coords of where you are going to.
    best practice if you have a config file, to write them in the file, call them as double and variable them.
    so later if you want to change x,y,z you dont have to recompile, and restart to change it.
    ( did that mistake thinking "i will never need to change where spawn point is on this map")

    that might cause problems, if your not telling it 'which' world it is, they will goto those coords in the current world.

    say you want them to spawn at 1,1,1 in 'world' and they die in nether, it doesn't know which world so it puts them at 1,1,1 in nether.

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

    chenr1

    Well, thanks for all of your responses but im getting console errors.
    Code:
                      World world = null;
                       
                      double z = 54;
                      double x = -11;
                      double y = 42;
                   
                     
                      player.teleport(new Location(world,x,y,z));
                
    And here is my error from the console
    Code:
    [SEVERE] Could not pass event PlayerRespawnEvent to PaintBall
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:304)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:459)
        at net.minecraft.server.ServerConfigurationManager.moveToWorld(ServerConfigurationManager.java:289)
        at net.minecraft.server.ServerConfigurationManager.moveToWorld(ServerConfigurationManager.java:248)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:1036)
        at net.minecraft.server.Packet9Respawn.handle(SourceFile:28)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:229)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113)
        at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:78)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:567)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:459)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.NullPointerException
        at org.bukkit.craftbukkit.entity.CraftPlayer.teleport(CraftPlayer.java:351)
        at org.bukkit.craftbukkit.entity.CraftEntity.teleport(CraftEntity.java:162)
        at com.goldmine.caleb.PaintBall.PaintBall.PlayerRespawn(PaintBall.java:229)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaP
     
  6. cause: world == null
    EDIT: you know about PlayerRespawnEvent.setRespawnLocation()?
     
    chenr1 likes this.
  7. Offline

    dxwarlock

    do
    World world = Bukkit.getWorld("whateverworldyouwant");
     
    chenr1 likes this.
  8. Offline

    chenr1

    lol THANKS!!! You guys ROCK!!

    Yes i do know about the resawn thing, this was just a test in a radom event.

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

    russjr08

    If you don't tell it which world, it'll get confused, that's why. You can't have it null :p
     
  10. Offline

    chenr1

    Cool, i understand know. You see Iwas taing java clases but im new to bukkit though.

    IFail seems funny btw.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
Thread Status:
Not open for further replies.

Share This Page