// Notify everyone
for (Team t : playerWarzone.getTeams()) {
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
SpoutDisplayer.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
victim.getKind().getMaterial(),
victim.getKind().getData(),
10000);
}
}
}
t.teamcast("zone.flagcapture.broadcast", playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE,
victim.getName(), playerTeam.getName());
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(playerTeam.getName());
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
victim.initializeTeamFlag();
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
}
}
playerWarzone.removeFlagThief(player.getName());
return;
}
}
// Bomb detonation
if (playerWarzone.isBombThief(player.getName())) {
// smoky
playerWarzone.getWorld().playEffect(player.getLocation(), Effect.SMOKE, 0);
// Make sure game ends can't occur simultaneously.
// Not thread safe. See Warzone.handleDeath() for details.
boolean inEnemySpawn = false;
Team victim = null;
for (Team team : playerWarzone.getTeams()) {
if (team != playerTeam
&& team.isSpawnLocation(player.getLocation())
&& team.getPlayers().size() > 0) {
inEnemySpawn = true;
victim = team;
break;
}
}
if (inEnemySpawn && playerTeam.getPlayers().contains(player)) {
// Made sure player is still part of team, game may have ended while waiting.
// Ignored the scorers that happened immediately after the game end.
Bomb bomb = playerWarzone.getBombForThief(player.getName());
// Boom!
if (!playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)) {
// Don't blow up if warzone is unbreakable
playerWarzone.getWorld().createExplosion(player.getLocation(), 2F);
}
if (playerWarzone.isReinitializing()) {
// Battle already ended or interrupted
playerWarzone.respawnPlayer(event, playerTeam, player);
} else {
// All good - proceed with scoring
playerTeam.addPoint();
// Notify everyone
for (Team t : playerWarzone.getTeams()) {
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " blew up "),
SpoutDisplayer.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + "'s spawn!"),
victim.getKind().getMaterial(),
victim.getKind().getData(),
10000);
}
}
}
t.teamcast("zone.bomb.broadcast", playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE,
victim.getName(), playerTeam.getName());
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(playerTeam.getName());
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
// restore bombed team's spawn
for (Volume spawnVolume : victim.getSpawnVolumes().values()) {
spawnVolume.resetBlocks();
}
victim.initializeTeamSpawns();
// bring back tnt
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
}
}
playerWarzone.removeBombThief(player.getName());
return;
}
}
// Cake retrieval
if (playerWarzone.isCakeThief(player.getName())) {
// smoky
if (System.currentTimeMillis() % 13 == 0) {
playerWarzone.getWorld().playEffect(player.getLocation(), Effect.POTION_BREAK, playerTeam.getKind().getPotionEffectColor());
}
// Make sure game ends can't occur simultaneously.
// Not thread safe. See Warzone.handleDeath() for details.
boolean inSpawn = playerTeam.isSpawnLocation(player.getLocation());
if (inSpawn && playerTeam.getPlayers().contains(player)) {
// Made sure player is still part of team, game may have ended while waiting.
// Ignored the scorers that happened immediately after the game end.
boolean hasOpponent = false;
for (Team t : playerWarzone.getTeams()) {
if (t != playerTeam && t.getPlayers().size() > 0) {
hasOpponent = true;
}
}
// Don't let someone alone make points off cakes
if (hasOpponent) {
Cake cake = playerWarzone.getCakeForThief(player.getName());
if (playerWarzone.isReinitializing()) {
// Battle already ended or interrupted
playerWarzone.respawnPlayer(event, playerTeam, player);
} else {
// All good - proceed with scoring
// Woot! Cake effect: 1 pt + full lifepool
playerTeam.addPoint();
playerTeam.setRemainingLives(playerTeam.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
// Notify everyone
for (Team t : playerWarzone.getTeams()) {
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "!"),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
10000);