Development Assistance All the players don't get teleported...

Discussion in 'Plugin Help/Development/Requests' started by metincasper, Jan 9, 2015.

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

    metincasper

    Hi
    I try to get all the players in a arraylist teleported to a location, but it's only one player that get teleported.

    Here is my teleporter method:
    Code:
        public void teleporter() {
               for (Player p : Bukkit.getOnlinePlayers()) {
                     if (join.contains(p)) {
                     if (timer <= 10) {
                         if (timer == 0) {
                                  World w = Bukkit.getWorld(getConfig().getString("Locations.arena.world"));
                                  double x = getConfig().getDouble("Locations.arena.X");
                                  double y = getConfig().getDouble("Locations.arena.Y");
                                  double z = getConfig().getDouble("Locations.arena.Z");
                                  p.teleport(new Location(w, x, y, z));
                                  stopScheduler();
                                  timer += 10;
                                  p.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD + "[FastPlayer] " + ChatColor.GREEN + "Gooo!!!");
                                  return;
                                 }
                                     p.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD + "[FastPlayer] " + ChatColor.LIGHT_PURPLE.toString() + ChatColor.BOLD.toString() + timer + "" + ChatColor.GREEN + " sekunder til start");                       
                                 }
                             }
                   
                 }
        }
    I call the method in a repeating task that look like this:
    Code:
        public void startScheduler(){
            this.taskId = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
                public void run(){
                    teleporter();
                      timer -= 1;
                 }
            }, 0L, 20L);
        }
    All players in the arraylist get the message:
    Code:
    p.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD + "[FastPlayer] " + ChatColor.LIGHT_PURPLE.toString() + ChatColor.BOLD.toString() + timer + "" + ChatColor.GREEN + " sekunder til start");
    But they don't get teleported
     
  2. Offline

    Lolmewn

    You add 10 to the timer, of course timer will be bigger or equal to 10 for the next iteration ;)
     
  3. Offline

    metincasper

    I tried to remove the part "timer += 10;" but that didnt help
     
Thread Status:
Not open for further replies.

Share This Page