Overcomplicate teleporting in team SG

Should (should) keep teammates together but actual teams separate.
This commit is contained in:
Spencer 2017-12-18 13:44:40 -05:00 committed by Alexander Meech
parent 940efc6163
commit aecf04483e

View File

@ -18,6 +18,7 @@ import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker;
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -206,4 +207,43 @@ public class TeamSurvivalGames extends SurvivalGames
{
return "Team Mode";
}
@Override
protected void deathmatchTeleport() {
List<Location> spawns = new ArrayList<>();
for (GameTeam team : GetTeamList())
{
spawns.addAll(team.GetSpawns());
}
List<Player> spectators = GetPlayers(false);
List<Player> living = GetPlayers(true);
spectators.removeAll(living);
Location spectatorLocation = GetSpectatorLocation();
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();
}
}
}