For looping through all online players then teleporting players only in certain lists is not working

Discussion in 'Plugin Development' started by Johnzeh, Dec 7, 2013.

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

    Johnzeh

    I've just started back up on this project last night and everything was going smoothly until I reached the point of which I have to teleport all players in two team lists. I've googled around and tried to find solutions and other ways of doing this but can't seem to find any way of fixing this. It does not log anything in the console, not a error or anything. Debugging by logging at every situation is not working either. I'm making sure all players are in the list, and I've made sure that my teleporting methods have worked in which they do.

    tl;dr I'm trying to teleport two different groups of players to two different locations and it is not logging any errors and also is doing nothing that would help me find a fix.

    Code for adding players:

    Code:java
    1. if(getStatus() == Status.WAITING) {
    2. p.setDisplayName(ChatColor.RED + pname + ChatColor.RESET);
    3. p.setPlayerListName(ChatColor.RED + pname + ChatColor.RESET);
    4.  
    5. Message.messageAsTeam(p, Message.joinedred);
    6.  
    7. clearPlayer(p, GameMode.SURVIVAL);
    8.  
    9. getLobbyList().remove(pname);
    10. getRedList().add(pname);
    11.  
    12. startPregamePhase();
    13. }


    Code for teleporting players once the pregame timer has reached zero:

    Code:java
    1. for(Player players : Bukkit.getOnlinePlayers()) {
    2. if(getRedList().contains(players.getName())) {
    3. players.teleport(Teleport.getRedLocation());
    4. clearPlayer(players, GameMode.SURVIVAL);
    5. }
    6.  
    7. else if(getBlueList().contains(players.getName())) {
    8. players.teleport(Teleport.getBlueLocation());
    9. clearPlayer(players, GameMode.SURVIVAL);
    10. }
    11. }


    And just for show, my methods upon getting and teleporting players:

    Code:java
    1. public static Location getRedLocation() {
    2. int x,y,z,yaw,pitch;
    3.  
    4. x = Main.getInstance().getConfig().getInt("Map.Red.Spawn.X");
    5. y = Main.getInstance().getConfig().getInt("Map.Red.Spawn.Y");
    6. z = Main.getInstance().getConfig().getInt("Map.Red.Spawn.Z");
    7. yaw = Main.getInstance().getConfig().getInt("Map.Red.Spawn.YAW");
    8. pitch = Main.getInstance().getConfig().getInt("Map.Red.Spawn.PITCH");
    9.  
    10. redloc = new Location(gameworld,x,y,z,yaw,pitch);
    11.  
    12. return redloc;
    13. }
    14.  
    15.  
    16. public static void teleportToRed(Player p) {
    17. p.teleport(getRedLocation());
    18. }


    Also I'm using players.teleport instead of teleportToRed because teleportToRed wasn't working and I wanted to try it this way, but still nothing has happened.
     
  2. Offline

    Wolfey

    Try this:
    Code:java
    1.  
    2. for(String str : getRedPlayers()) {
    3. Player player = Bukkit.getPlayer(str);
    4. if(player != null) player.teleport(getRedLocation());
    5. }
    6. for(String str : getBluePlayers()) {
    7. Player player = Bukkit.getPlayer(str);
    8. if(player != null) player.teleport(getBlueLocation());
    9. }
    10.  
     
  3. Offline

    Johnzeh

    Already tried that, same results.
     
  4. Offline

    Wolfey

    That always works for me. Are you sure you're using it right?
     
  5. Offline

    Johnzeh

    Well I'm showing you exactly how I'm doing it. I got that from another bukkit post that worked for the person who needed it but sadly isn't working for me. Everything that would cause this problem is shown in the original post.
     
  6. Everything is registered correctly?
     
  7. Offline

    Johnzeh

    Yep! Everything works EXCEPT teleporting upon the timer reaching zero.
     
Thread Status:
Not open for further replies.

Share This Page