/** * Teleports player to their team spawn * * @param player The player that is being teleported */ public void teleportPlayer(Player player) { Location spawn = getSpawnLoc(player); if (isSpawnValid(spawn)) { player.teleport(spawn); SnowballFight.announce(player.getName() + " has spawned!"); } else { SnowballFight.log("Player has no team!"); } }
/** * Adds player to the appropriate team * * @param player The player to add to the team */ public void joinPlayer(Player player) { if (getPlayerTeam(player) == null) { Team teamToJoin = getTeamToJoin(); teamToJoin.addPlayer(player); teleportPlayer(player); SnowballFight.announce(player.getName() + " has joined " + teamToJoin.getTeamName() + "!"); } else { SnowballFight.log(player.getName() + " is already on " + getPlayerTeam(player) + "!"); } }
/** * Gets the team that the specified player is on * * @param player The player to check * @return The team that the player is on */ public Team getPlayerTeam(Player player) { if (team1.isOnTeam(player)) { return team1; } else if (team2.isOnTeam(player)) { return team2; } else { SnowballFight.log(player.getName() + " has no team!"); return null; } }
/** * Updates player info * * @param killer The killer * @param player The person that was killed */ public void onPlayerKill(Player killer, Player player) { SnowballFight.announce(killer + " has killed " + player + "!"); addKill(killer); addDeath(player); }