Development Assistance Help with teleporting

Discussion in 'Plugin Help/Development/Requests' started by Cuvthe3rd, Jan 1, 2015.

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

    Cuvthe3rd

    I've been making a minigame plugin recently, but i can't get this to work. The problem is that during the countdown the players get teleported to the arena. But if the arena is in another world to the player, it won't teleport the player.

    Link to the countdown code:

    http://pastebin.com/8Pj28WzH


    This is the part that doesn't work:
    http://pastebin.com/uFm4tVez

    Code:
    for(Player online : Bukkit.getOnlinePlayers()) {
                                                    if(p1.contains(online.getName())) {
                                                        online.sendMessage(WHITE+"["+GOLD+""+BOLD+"P"+YELLOW+""+BOLD+"S"+WHITE+"]"+YELLOW+" Teleporting To Arena");
                                                        int x = yamlFile.getInt("pos1.x");
                                                        int y = yamlFile.getInt("pos1.y");
                                                        int z = yamlFile.getInt("pos1.z");
                                                        int yaw = yamlFile.getInt("pos1.yaw");
                                                        int pitch = yamlFile.getInt("pos1.pitch");
                                                        Location loc1 = new Location(Bukkit.getWorld(yamlFile.getString("pos1.world")), x + 0.5, y, z + 0.5, yaw, pitch);
                                                        online.teleport(loc1);
                                                        m.add(online.getName());
    
                                                        online.getInventory().clear();
                                                        ItemStack potato = new ItemStack(Material.BAKED_POTATO);
                                                        ItemMeta potatoMeta = potato.getItemMeta();
                                                        potatoMeta.setDisplayName(GOLD+""+BOLD+"Potato Smash");
                                                        potatoMeta.addEnchant(Enchantment.KNOCKBACK, 6, true);
                                                        potato.setItemMeta(potatoMeta);
    
                                                        online.getInventory().addItem(potato);
                                                    }
    
                                                    if(p2.contains(online.getName())) {
                                                        online.sendMessage(WHITE+"["+GOLD+""+BOLD+"P"+YELLOW+""+BOLD+"S"+WHITE+"]"+YELLOW+" Teleporting To Arena");
                                                        int x = yamlFile.getInt("pos2.x");
                                                        int y = yamlFile.getInt("pos2.y");
                                                        int z = yamlFile.getInt("pos2.z");
                                                        int yaw = yamlFile.getInt("pos2.yaw");
                                                        int pitch = yamlFile.getInt("pos2.pitch");
                                                        Location loc2 = new Location(Bukkit.getWorld(yamlFile.getString("pos2.world")), x + 0.5, y, z + 0.5, yaw, pitch);
                                                        online.teleport(loc2);
                                                        m.add(online.getName());
    
                                                        online.getInventory().clear();
                                                        ItemStack potato = new ItemStack(Material.BAKED_POTATO);
                                                        ItemMeta potatoMeta = potato.getItemMeta();
                                                        potatoMeta.setDisplayName(GOLD+""+BOLD+"Potato Smash");
                                                        potatoMeta.addEnchant(Enchantment.KNOCKBACK, 6, true);
                                                        potato.setItemMeta(potatoMeta);
    
                                                        online.getInventory().addItem(potato);
                                                    }
                                                }
    
     
    Last edited: Jan 1, 2015
  2. Offline

    CheesyFreezy

    Whenever you set a spawn for something also save the world in the file. If you want to get the location that's saved in the file, than do this:

    Code:
    World world = Bukkit.getServer().getWorld(/*World name in here*/);
    Location location = new Location(world, x, y, z);
    
    player.teleport(location);
     
Thread Status:
Not open for further replies.

Share This Page