Use teleportUniform for deathmatchTeleport in teams

This commit is contained in:
Spencer 2017-12-28 20:33:13 -05:00 committed by Alexander Meech
parent 04b7986da6
commit 56a8e03204

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.updater.UpdateType;
@ -210,12 +211,7 @@ public class TeamSurvivalGames extends SurvivalGames
@Override
protected void deathmatchTeleport() {
List<Location> spawns = new ArrayList<>();
for (GameTeam team : GetTeamList())
{
spawns.addAll(team.GetSpawns());
}
List<Location> spawns = GetTeamList().get(0).GetSpawns();
List<Player> spectators = GetPlayers(false);
@ -227,23 +223,6 @@ public class TeamSurvivalGames extends SurvivalGames
spectators.forEach(s -> s.teleport(spectatorLocation));
// Find the number of spaces between each player,
int spacesBetween = Math.max(Math.floorDiv(spawns.size(), living.size()), 1);
int spaceIndex = 0;
// Teleport the players to locations every [spacesBetween] spaces
for (Player player : living)
{
GameTeam team = GetTeam(player);
List<Player> teamPlayers = team.GetPlayers(true);
for (int teamIndex = 0; teamIndex < teamPlayers.size(); teamIndex++)
{
player.teleport(spawns.get(spaceIndex + teamIndex));
}
// Wrap around if it overflows
spaceIndex = (spaceIndex + spacesBetween) % spawns.size();
}
UtilPlayer.teleportUniform(living, spawns);
}
}