[SOLVED] Multispawn's for minigame.

Discussion in 'Spigot Plugin Development' started by iFire140, May 20, 2015.

  1. 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++;
          }
      }
    }
     
  2. Whats the code in Locations.getLoc() ?
     
    #2 ewized, May 20, 2015
    Last edited: May 20, 2015
  3. 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();
        }
     
  4. 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.
     
    • Agree Agree x 2
  5. Ew, static… Are you using this as a Utility?
     
  6. Yeah, now working thanks