JoinEvent teleport player to and player1 to

Discussion in 'Spigot Plugin Development' started by GoRoK, Jun 25, 2016.

  1. Hey, i want to teleport Player to Loc 100 100 100 (example) and Player1 to Loc 200 200 200
    But im not too sure how to get 2 different Players and teleport them..
    The Spawns are set in the Config.
    My current code
    Code (Text):

            String pname = e.getPlayer().getDisplayName();
            e.setJoinMessage(ChatColor.BLUE + "[" + ChatColor.AQUA + "JumpBattle" + ChatColor.BLUE + "] " + pname + ChatColor.GRAY + " ist dem Spiel beigetreten.");
            World world = p.getWorld();
            int x = plugin.getConfig().getInt("Jump_Battle.SpawnX");
            int y = plugin.getConfig().getInt("Jump_Battle.SpawnY");
            int z = plugin.getConfig().getInt("Jump_Battle.SpawnZ");
            int x1 = plugin.getConfig().getInt("Jump_Battle1.SpawnX");
            int y1 = plugin.getConfig().getInt("Jump_Battle1.SpawnY");
            int z1 = plugin.getConfig().getInt("Jump_Battle1.SpawnZ");
            Location player1 = new Location(world, x, y, z);
            Location player2= new Location(world, x1, y1, z1);
            int size = online.size();
            Random r = new Random();
            size = r.nextInt(size);
    online is an ArrayList<Player>
    Code (Text):
     public ArrayList<Player> online = new ArrayList<>();
    Thanks for any help..
  2. First: you should always avoid storing a player object in a List, Hashmap,... Because of memory leaks. . If you are a really good dev and you know all cases where bukkit removes the player instances from the game and you handle that properly then ignore my warning.
    For more details Google.

  3. First: Thanks for the Info

    Imgtfy link, i know how to get Players,
    spigot link 1, i know the teleport methods

    i know how to get the onlineplayers,

    But i still dont know how to teleport the first player that joined to x and second one to y...
  4. Save theire name/UUID in a list or what ever when they join and then teleport them.
  5. But where can i say to which location? ... Im not that into Lits / Maps..
    When i get the name i do
    But then both get teleported to the same loc...