Solved teleporting all players in an arraylist?

Discussion in 'Plugin Development' started by 1Camer0471, Jan 8, 2015.

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

    1Camer0471

    So I'm trying to teleport all players that are playing to game to a certain place, NOT all player that are online, only the ones inside the arraylist. he is the code I am using:

    Code:
    ArrayList<String> totele = new ArrayList<>();
    Location startloc = new Location(player.getWorld(), startinglocx, startinglocy, startinglocz);
                                        for(String totp : totele) {
                                            Bukkit.getServer().getPlayer(totp).teleport(startloc);
                                        }
    it is telling me that The method getPlayer(String) from the type Server is deprecated
     
  2. Offline

    nverdier

    @1Camer0471 It's deprecated, but it still works. But you could just store the UUID's of the player and Bukkit#getPlayer(UUID) isn't deprecated.
     
    1Camer0471 likes this.
  3. Offline

    1Camer0471

    Thanks! <3
     
  4. Offline

    WampyCakes

    Use Bukkit.getPlayer with the player's UUID in the ArrayList instead of the Player's name. And you didn't define the ArrayList. You defined the List as a String, so define the ArrayList as a string as well.
     
Thread Status:
Not open for further replies.

Share This Page