Buggy code:
public class UHGameManager { private final Boolean RANDOM_COLORS_IN_SOLO ; private final Boolean BROADCAST_SLOW_START_PROGRESS ; private final UHSound DEATH_SOUND ; private UHCReloaded p = null ; private TeamManager tm = null ; private I18n i = null ; private Random random = null ; private Boolean damageIsOn = false ; private HashSet < String > players = new HashSet < > ( ) ; private HashSet < UUID > alivePlayers = new HashSet < > ( ) ; private HashSet < UHTeam > aliveTeams = new HashSet < > ( ) ; private HashSet < UUID > spectators = new HashSet < > ( ) ; private Map < UUID , Location > deathLocations = new HashMap < > ( ) ; private HashSet < String > deadPlayersToBeResurrected = new HashSet < > ( ) ; private Integer alivePlayersCount = 0 ; private Integer aliveTeamsCount = 0 ; private Boolean gameWithTeams = true ; private Boolean slowStartInProgress = false ; private Boolean slowStartTPFinished = false ; private Boolean gameStarted = false ; private Boolean gameFinished = false ; private Integer episode = 0 ; private Teleporter teleporter = null ; public static final String FINISH_ERROR_NOT_STARTED = "Unable<seq2seq4repair_space>to<seq2seq4repair_space>finish<seq2seq4repair_space>the<seq2seq4repair_space>game:<seq2seq4repair_space>the<seq2seq4repair_space>game<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>started" ; public static final String FINISH_ERROR_NOT_FINISHED = "Unable<seq2seq4repair_space>to<seq2seq4repair_space>finish<seq2seq4repair_space>the<seq2seq4repair_space>game:<seq2seq4repair_space>the<seq2seq4repair_space>game<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>finished" ; public UHGameManager ( UHCReloaded plugin ) { } public void initEnvironment ( ) { } public void initPlayer ( final Player player ) { } public void start ( final CommandSender sender , final Boolean slow , Boolean ignoreTeams ) throws IllegalStateException { if ( isGameRunning ( ) ) { throw new IllegalStateException ( "The<seq2seq4repair_space>game<seq2seq4repair_space>is<seq2seq4repair_space>currently<seq2seq4repair_space>running!" ) ; } p . getMOTDManager ( ) . updateMOTDDuringStart ( ) ; alivePlayers . clear ( ) ; aliveTeams . clear ( ) ; alivePlayersCount = 0 ; aliveTeamsCount = 0 ; Set < UHTeam > onTheFlyTeams = new HashSet < > ( ) ; if ( tm . getTeams ( ) . isEmpty ( ) ) { gameWithTeams = false ; for ( Player player : Bukkit . getOnlinePlayers ( ) ) { if ( ! ( spectators . contains ( player . getUniqueId ( ) ) ) ) { UHTeam team = new UHTeam ( player . getName ( ) , ( RANDOM_COLORS_IN_SOLO ? TeamColor . RANDOM : null ) ) ; team . addPlayer ( player , true ) ; tm . addTeam ( team ) ; onTheFlyTeams . add ( team ) ; } } } else { gameWithTeams = true ; for ( Player player : Bukkit . getOnlinePlayers ( ) ) { <START_BUG> if ( ! ( spectators . contains ( player . getUniqueId ( ) ) ) ) { <END_BUG> String teamName = player . getName ( ) ; while ( tm . isTeamRegistered ( teamName ) ) { teamName = ( ( player . getName ( ) ) + "<seq2seq4repair_space>" ) + ( random . nextInt ( 1000000 ) ) ; } UHTeam team = new UHTeam ( teamName , ( RANDOM_COLORS_IN_SOLO ? TeamColor . RANDOM : null ) ) ; team . addPlayer ( player , true ) ; tm . addTeam ( team ) ; onTheFlyTeams . add ( team ) ; } } } for ( UHTeam team : tm . getTeams ( ) ) { for ( OfflinePlayer player : team . getPlayers ( ) ) { if ( ! ( spectators . contains ( player . getUniqueId ( ) ) ) ) { alivePlayers . add ( player . getUniqueId ( ) ) ; } } } updateAliveCache ( ) ; Integer spawnsNeeded = ( ignoreTeams ) ? alivePlayersCount : aliveTeamsCount ; if ( ( p . getSpawnsManager ( ) . getSpawnPoints ( ) . size ( ) ) < spawnsNeeded ) { sender . sendMessage ( i . t ( "start.notEnoughTP" ) ) ; for ( UHTeam team : onTheFlyTeams ) { tm . removeTeam ( team , true ) ; } aliveTeamsCount = 0 ; alivePlayersCount = 0 ; return ; } if ( p . getSpectatorPlusIntegration ( ) . isSPIntegrationEnabled ( ) ) { for ( Player player : Bukkit . getOnlinePlayers ( ) ) { p . getSpectatorPlusIntegration ( ) . getSPAPI ( ) . setSpectating ( player , spectators . contains ( player . getUniqueId ( ) ) ) ; } } teleporter = new Teleporter ( ) ; List < Location > spawnPoints = new java . util . ArrayList ( p . getSpawnsManager ( ) . getSpawnPoints ( ) ) ; Collections . shuffle ( spawnPoints ) ; Queue < Location > unusedTP = new java . util . ArrayDeque ( spawnPoints ) ; for ( final UHTeam team : tm . getTeams ( ) ) { if ( team . isEmpty ( ) ) continue ; if ( ! ignoreTeams ) { Location teamSpawn = unusedTP . poll ( ) ; for ( UUID player : team . getPlayersUUID ( ) ) { teleporter . setSpawnForPlayer ( player , teamSpawn ) ; } } else { for ( UUID player : team . getPlayersUUID ( ) ) { teleporter . setSpawnForPlayer ( player , unusedTP . poll ( ) ) ; } } } if ( slow ) { slowStartInProgress = true ; slowStartTPFinished = false ; p . getFreezer ( ) . setGlobalFreezeState ( true , false ) ; p . getServer ( ) . broadcastMessage ( i . t ( "start.teleportationInProgress" ) ) ; teleporter . whenTeleportationOccurs ( new fr . zcraft . zlib . tools . Callback < UUID > ( ) { private int teleported = 0 ; private int total = alivePlayersCount ; @ Override public void call ( UUID uuid ) { ( teleported ) ++ ; if ( BROADCAST_SLOW_START_PROGRESS ) { String message = i . t ( "start.teleportationInProgressInActionBar" , teleported , total ) ; for ( Player player : Bukkit . getOnlinePlayers ( ) ) { ActionBar . sendPermanentMessage ( player , message ) ; } } } } ) ; }

Fix:
if ( ( ! ( spectators . contains ( player . getUniqueId ( ) ) ) ) && ( ( tm . getTeamForPlayer ( player ) ) == null ) ) {