I need you to teleport to 6 players on one team placed at different points , I tried this method but the problem is that does not work, or is still sending players to the same point , it does no error in the console. Code (Text): public static void teleportPoint(String map, Player p){ File file = new File("plugins/TeamSkywars/config/"+map+".yml"); YamlConfiguration config = new YamlConfiguration().loadConfiguration(file); for(Player ps : Bukkit.getOnlinePlayers()){ if(Team.blue.contains(ps)){ int i = 0; Location loc = Locations.getLoc(config.getString("arenaSpawns.team1.point"+i)); ps.teleport(loc); i++; } } }
Code (Text): public static Location getLoc(String path){ Location loc = null; String[] locs = path.split(","); loc = new Location(Bukkit.getWorld(locs[0]), Integer.parseInt(locs[1]), Integer.parseInt(locs[2]), Integer.parseInt(locs[3])); loc.add(0.5D, 0.0D, 0.5D); return loc; } and set loc is this Code (Text): public static String setLoc(Location loc) { return loc.getWorld().getName()+","+loc.getBlockX()+","+loc.getBlockY()+","+loc.getBlockZ(); }
From what I see, you may need to set your variable "I" outside the for loop. What your doing is after i++, it resets back to 0 because it iterates over again.