First attempt at fixing no-inv-reset/over-maxscore bug. When a battle or the game ends, extra simultaneous deaths or scorers shouldn't cause duplicate warzone resets anymore. Knock on wood, i.e. needs testing. Also, added RESETONCONFIGCHANGED setting that is false by default - i.e. /zonecfg and /teamcfg won't cause a zone reset automatically anymore.

This commit is contained in:
taoneill 2012-04-06 21:35:30 -04:00
parent 6b29226004
commit 2c773710ba
9 changed files with 299 additions and 208 deletions

View File

@ -155,6 +155,7 @@ public class War extends JavaPlugin {
warzoneDefaultConfig.put(WarzoneConfig.PVPINZONE, true);
warzoneDefaultConfig.put(WarzoneConfig.REALDEATHS, false);
warzoneDefaultConfig.put(WarzoneConfig.RESETONEMPTY, false);
warzoneDefaultConfig.put(WarzoneConfig.RESETONCONFIGCHANGE, false);
warzoneDefaultConfig.put(WarzoneConfig.RESETONLOAD, false);
warzoneDefaultConfig.put(WarzoneConfig.RESETONUNLOAD, false);
warzoneDefaultConfig.put(WarzoneConfig.UNBREAKABLE, false);

View File

@ -77,6 +77,9 @@ public class Warzone {
private final WarzoneConfigBag warzoneConfig;
private final TeamConfigBag teamDefaultConfig;
private InventoryBag defaultInventories = new InventoryBag();
private boolean isEndOfGame = false;
private boolean isReinitializing = false;
public Warzone(World world, String name) {
this.world = world;
@ -239,7 +242,15 @@ public class Warzone {
}
this.initZone();
if (War.war.getWarHub() != null) {
War.war.getWarHub().resetZoneSign(this);
}
}
// Don't forget to reset these to false, or we won't be able to score or empty lifepools anymore
this.isReinitializing = false;
this.isEndOfGame = false;
}
public void initializeZoneAsJob(Player respawnExempted) {
@ -799,89 +810,98 @@ public class Warzone {
public void handleDeath(Player player) {
Team playerTeam = Team.getTeamByPlayerName(player.getName());
Warzone playerWarzone = Warzone.getZoneByPlayerName(player.getName());
if (playerTeam != null && playerWarzone != null) {
if (playerTeam != null) {
// teleport to team spawn upon fast respawn death, but not for real deaths
if (!playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
playerWarzone.respawnPlayer(playerTeam, player);
if (!this.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
this.respawnPlayer(playerTeam, player);
} else {
// onPlayerRespawn takes care of real deaths
//player.setHealth(0);
playerWarzone.getReallyDeadFighters().add(player.getName());
this.getReallyDeadFighters().add(player.getName());
}
int remaining = playerTeam.getRemainingLifes();
if (remaining == 0) { // your death caused your team to lose
List<Team> teams = playerWarzone.getTeams();
String scores = "";
for (Team t : teams) {
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutDisplayer.cleanForNotification("Round over! " + playerTeam.getKind().getColor() + playerTeam.getName()),
SpoutDisplayer.cleanForNotification("ran out of lives."),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
10000);
if (this.isEndOfGame) {
// Prevent duplicate game end. You died just after the game ending death/point. Too bad!
this.gameEndTeleport(player);
} else if (this.isReinitializing) {
// Prevent duplicate battle end. You died just after the battle ending death.
this.respawnPlayer(playerTeam, player);
} else {
// Handle team loss
List<Team> teams = this.getTeams();
String scores = "";
for (Team t : teams) {
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutDisplayer.cleanForNotification("Round over! " + playerTeam.getKind().getColor() + playerTeam.getName()),
SpoutDisplayer.cleanForNotification("ran out of lives."),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
10000);
}
}
}
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: " + player.getName() + " died and there were no lives left in their life pool.");
if (t.getPlayers().size() != 0 && !t.getTeamConfig().resolveBoolean(TeamConfig.FLAGPOINTSONLY)) {
if (!t.getName().equals(playerTeam.getName())) {
// all other teams get a point
t.addPoint();
t.resetSign();
}
scores += t.getName() + "(" + t.getPoints() + "/" + t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE) + ") ";
}
}
if (!scores.equals("")) {
for (Team t : teams) {
t.teamcast("New scores - " + scores);
}
}
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: " + player.getName() + " died and there were no lives left in their life pool.");
if (t.getPlayers().size() != 0 && !t.getTeamConfig().resolveBoolean(TeamConfig.FLAGPOINTSONLY)) {
if (!t.getName().equals(playerTeam.getName())) {
// all other teams get a point
t.addPoint();
t.resetSign();
}
scores += t.getName() + "(" + t.getPoints() + "/" + t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE) + ") ";
}
}
if (!scores.equals("")) {
// detect score cap
List<Team> scoreCapTeams = new ArrayList<Team>();
for (Team t : teams) {
t.teamcast("New scores - " + scores);
}
}
// detect score cap
List<Team> scoreCapTeams = new ArrayList<Team>();
for (Team t : teams) {
if (t.getPoints() == t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
scoreCapTeams.add(t);
}
}
if (!scoreCapTeams.isEmpty()) {
String winnersStr = "";
for (Team winner : scoreCapTeams) {
if (winner.getPlayers().size() != 0) {
winnersStr += winner.getName() + " ";
if (t.getPoints() == t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
scoreCapTeams.add(t);
}
}
playerWarzone.handleScoreCapReached(player, winnersStr);
// player.teleport(playerWarzone.getTeleport());
// player will die because it took too long :(
// we dont restore his inventory in handleScoreCapReached
// check out PLAYER_MOVE for the rest of the fix
} else {
// A new battle starts. Reset the zone but not the teams.
for (Team t : teams) {
t.teamcast("A new battle begins. Resetting warzone...");
if (!scoreCapTeams.isEmpty()) {
String winnersStr = "";
for (Team winner : scoreCapTeams) {
if (winner.getPlayers().size() != 0) {
winnersStr += winner.getName() + " ";
}
}
this.handleScoreCapReached(player, winnersStr);
// player.teleport(playerWarzone.getTeleport());
// player will die because it took too long :(
// we dont restore his inventory in handleScoreCapReached
// check out PLAYER_MOVE for the rest of the fix
} else {
// A new battle starts. Reset the zone but not the teams.
for (Team t : teams) {
t.teamcast("A new battle begins. Resetting warzone...");
}
this.reinitialize(player);
}
playerWarzone.getVolume().resetBlocksAsJob();
playerWarzone.initializeZoneAsJob(player);
}
} else {
// player died without causing his team's demise
if (playerWarzone.isFlagThief(player.getName())) {
if (this.isFlagThief(player.getName())) {
// died while carrying flag.. dropped it
Team victim = playerWarzone.getVictimTeamForFlagThief(player.getName());
Team victim = this.getVictimTeamForFlagThief(player.getName());
victim.getFlagVolume().resetBlocks();
victim.initializeTeamFlag();
playerWarzone.removeFlagThief(player.getName());
this.removeFlagThief(player.getName());
if (War.war.isSpoutServer()) {
for (Player p : victim.getPlayers()) {
@ -897,20 +917,20 @@ public class Warzone {
}
}
for (Team t : playerWarzone.getTeams()) {
for (Team t : this.getTeams()) {
t.teamcast(player.getName() + " died and dropped team " + victim.getName() + "'s flag.");
}
}
// Bomb thieves
if (playerWarzone.isBombThief(player.getName())) {
if (this.isBombThief(player.getName())) {
// died while carrying bomb.. dropped it
Bomb bomb = playerWarzone.getBombForThief(player.getName());
Bomb bomb = this.getBombForThief(player.getName());
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
playerWarzone.removeBombThief(player.getName());
this.removeBombThief(player.getName());
for (Team t : playerWarzone.getTeams()) {
for (Team t : this.getTeams()) {
t.teamcast(player.getName() + " died and dropped bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.WHITE + ".");
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
@ -928,14 +948,14 @@ public class Warzone {
}
}
if (playerWarzone.isCakeThief(player.getName())) {
if (this.isCakeThief(player.getName())) {
// died while carrying cake.. dropped it
Cake cake = playerWarzone.getCakeForThief(player.getName());
Cake cake = this.getCakeForThief(player.getName());
cake.getVolume().resetBlocks();
cake.addCakeBlocks();
playerWarzone.removeCakeThief(player.getName());
this.removeCakeThief(player.getName());
for (Team t : playerWarzone.getTeams()) {
for (Team t : this.getTeams()) {
t.teamcast(player.getName() + " died and dropped cake " + ChatColor.GREEN + cake.getName() + ChatColor.WHITE + ".");
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
@ -953,10 +973,12 @@ public class Warzone {
}
}
// Lifepool empty warning
// Decrement lifepool
playerTeam.setRemainingLives(remaining - 1);
// Lifepool empty warning
if (remaining - 1 == 0) {
for (Team t : playerWarzone.getTeams()) {
for (Team t : this.getTeams()) {
t.teamcast("Team " + playerTeam.getName() + "'s life pool is empty. One more death and they lose the battle!");
}
}
@ -965,6 +987,18 @@ public class Warzone {
}
}
private void reinitialize(Player player) {
this.isReinitializing = true;
this.getVolume().resetBlocksAsJob();
this.initializeZoneAsJob(player);
}
public void reinitialize() {
this.isReinitializing = true;
this.getVolume().resetBlocksAsJob();
this.initializeZoneAsJob();
}
public void handlePlayerLeave(Player player, Location destination, PlayerMoveEvent event, boolean removeFromTeam) {
this.handlePlayerLeave(player, removeFromTeam);
event.setTo(destination);
@ -1170,14 +1204,10 @@ public class Warzone {
public void handleScoreCapReached(Player player, String winnersStr) {
// Score cap reached. Reset everything.
this.isEndOfGame = true;
ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr);
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
this.getVolume().resetBlocksAsJob();
this.initializeZoneAsJob(player);
if (War.war.getWarHub() != null) {
// TODO: test if warhub sign gives the correct info despite the jobs
War.war.getWarHub().resetZoneSign(this);
}
this.reinitialize(player);
}
// public void setSpawnStyle(TeamSpawnStyle spawnStyle) {
@ -1313,4 +1343,26 @@ public class Warzone {
public List<String> getReallyDeadFighters() {
return this.reallyDeadFighters ;
}
public void gameEndTeleport(Player tp) {
if (this.getRallyPoint() != null) {
tp.teleport(this.getRallyPoint());
} else {
tp.teleport(this.getTeleport());
}
tp.setFireTicks(0);
tp.setRemainingAir(300);
if (this.hasPlayerState(tp.getName())) {
this.restorePlayerState(tp);
}
}
public boolean isEndOfGame() {
return this.isEndOfGame;
}
public boolean isReinitalizing() {
return this.isReinitializing;
}
}

View File

@ -42,8 +42,7 @@ public class NextBattleCommand extends AbstractZoneMakerCommand {
for (Team team : zone.getTeams()) {
team.teamcast("The battle was interrupted. " + zone.getTeamInformation() + " Resetting warzone " + zone.getName() + " and life pools...");
}
zone.getVolume().resetBlocksAsJob();
zone.initializeZoneAsJob();
zone.reinitialize();
return true;
}

View File

@ -54,11 +54,10 @@ public class ResetZoneCommand extends AbstractZoneMakerCommand {
}
this.msg("Reloading warzone " + zone.getName() + ".");
zone.getVolume().resetBlocksAsJob();
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocksAsJob();
}
zone.initializeZoneAsJob();
zone.reinitialize();
return true;
}

View File

@ -8,6 +8,7 @@ import com.tommytony.war.Team;
import com.tommytony.war.War;
import com.tommytony.war.Warzone;
import com.tommytony.war.config.TeamKind;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.mapper.WarzoneYmlMapper;
import com.tommytony.war.structure.ZoneLobby;
@ -131,18 +132,22 @@ public class SetTeamConfigCommand extends AbstractZoneMakerCommand {
// We have a warzone, a team and indexed-from-0 arguments, let's update
String namedParamReturn = War.war.updateTeamFromNamedParams(team, player, this.args);
if (!namedParamReturn.equals("") && !namedParamReturn.equals("PARSE-ERROR")) {
this.msg("Saving config and resetting warzone " + zone.getName() + ".");
WarzoneYmlMapper.save(zone, false);
zone.getVolume().resetBlocks();
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();
}
zone.initializeZone(); // bring back team spawns etc
String zoneReset = "Some changes may require a /resetzone. ";
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.RESETONCONFIGCHANGE)) {
zone.reinitialize(); // bring back team spawns etc
zoneReset = "Zone reset. ";
}
if (wantsToPrint) {
this.msg("Team config saved. Zone reset." + namedParamReturn + " " + War.war.printConfig(team));
this.msg("Team config saved. " + zoneReset + namedParamReturn + " " + War.war.printConfig(team));
} else {
this.msg("Team config saved. Zone reset." + namedParamReturn);
this.msg("Team config saved. " + zoneReset + namedParamReturn);
}
if (War.war.getWarHub() != null) { // maybe the zone was disabled/enabled

View File

@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
import com.tommytony.war.War;
import com.tommytony.war.Warzone;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.mapper.WarzoneYmlMapper;
import com.tommytony.war.structure.ZoneLobby;
@ -92,18 +93,22 @@ public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
// We have a warzone and indexed-from-0 arguments, let's update
String namedParamReturn = War.war.updateZoneFromNamedParams(zone, player, this.args);
if (!namedParamReturn.equals("") && !namedParamReturn.equals("PARSE-ERROR")) {
this.msg("Saving config and resetting warzone " + zone.getName() + ".");
WarzoneYmlMapper.save(zone, false);
zone.getVolume().resetBlocks();
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();
}
zone.initializeZone(); // bring back team spawns etc
String zoneReset = "Some changes may require a /resetzone. ";
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.RESETONCONFIGCHANGE)) {
zone.reinitialize(); // bring back team spawns etc
zoneReset = "Zone reset. ";
}
if (wantsToPrint) {
this.msg("Warzone config saved. Zone reset." + namedParamReturn + " " + War.war.printConfig(zone));
this.msg("Warzone config saved. " + zoneReset + namedParamReturn + " " + War.war.printConfig(zone));
} else {
this.msg("Warzone config saved. Zone reset." + namedParamReturn);
this.msg("Warzone config saved. " + zoneReset + namedParamReturn);
}
if (War.war.getWarHub() != null) { // maybe the zone was disabled/enabled

View File

@ -16,6 +16,7 @@ public enum WarzoneConfig {
PVPINZONE (Boolean.class),
REALDEATHS (Boolean.class),
RESETONEMPTY (Boolean.class),
RESETONCONFIGCHANGE (Boolean.class),
RESETONLOAD (Boolean.class),
RESETONUNLOAD (Boolean.class),
UNBREAKABLE (Boolean.class);

View File

@ -508,44 +508,57 @@ public class WarPlayerListener implements Listener {
War.war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned.");
} else {
// flags can be captured at own spawn or own flag pole
playerTeam.addPoint();
Team victim = playerWarzone.getVictimTeamForFlagThief(player.getName());
// 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(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " captured team " + victim.getName() + "'s flag. Team " + playerTeam.getName() + " scores one point.");
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.isEndOfGame()) {
// max already reached - game has already ended. Too bad!
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(player, playerTeam.getName());
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
victim.initializeTeamFlag();
} else if (playerWarzone.isReinitalizing()) {
// Battle already ended or interrupted
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
} else {
// All good - proceed with scoring
playerTeam.addPoint();
Team victim = playerWarzone.getVictimTeamForFlagThief(player.getName());
// 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(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " captured team " + victim.getName() + "'s flag. Team " + playerTeam.getName() + " scores one point.");
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(player, 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());
}
@ -578,48 +591,60 @@ public class WarPlayerListener implements Listener {
playerWarzone.getWorld().createExplosion(player.getLocation(), 2F);
}
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(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " blew up team " + victim.getName() + "'s spawn. Team " + playerTeam.getName() + " scores one point.");
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.isEndOfGame()) {
// max already reached - game has already ended. Too bad!
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(player, playerTeam.getName());
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
// bring back flag to team that lost it
victim.getSpawnVolume().resetBlocks();
victim.initializeTeamSpawn();
// bring back tnt
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
} else if (playerWarzone.isReinitalizing()) {
// Battle already ended or interrupted
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
} 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(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " blew up team " + victim.getName() + "'s spawn. Team " + playerTeam.getName() + " scores one point.");
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(player, playerTeam.getName());
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
// restore bombed team's spawn
victim.getSpawnVolume().resetBlocks();
victim.initializeTeamSpawn();
// bring back tnt
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
}
}
playerWarzone.removeBombThief(player.getName());
@ -649,47 +674,59 @@ public class WarPlayerListener implements Listener {
if (hasOpponent) {
Cake cake = playerWarzone.getCakeForThief(player.getName());
// Woot!
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);
}
}
}
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " captured cake " + ChatColor.GREEN + cake.getName() + ChatColor.WHITE + ". Team " + playerTeam.getName() + " scores one point and gets a full lifepool.");
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.isEndOfGame()) {
// max already reached - game has already ended. Too bad!
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(player, playerTeam.getName());
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
// bring back cake
cake.getVolume().resetBlocks();
cake.addCakeBlocks();
} else if (playerWarzone.isReinitalizing()) {
// Battle already ended or interrupted
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
} 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);
}
}
}
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " captured cake " + ChatColor.GREEN + cake.getName() + ChatColor.WHITE + ". Team " + playerTeam.getName() + " scores one point and gets a full lifepool.");
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(player, playerTeam.getName());
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
// bring back cake
cake.getVolume().resetBlocks();
cake.addCakeBlocks();
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
}
}
playerWarzone.removeCakeThief(player.getName());

View File

@ -43,16 +43,8 @@ public class ScoreCapReachedJob implements Runnable {
t.teamcast(winnersStrAndExtra);
for (Player tp : t.getPlayers()) {
// Send everyone to rally point (or zone lobby if not rally point)
if (this.zone.getRallyPoint() != null) {
tp.teleport(this.zone.getRallyPoint());
} else {
tp.teleport(this.zone.getTeleport());
}
tp.setFireTicks(0);
tp.setRemainingAir(300);
if (this.zone.hasPlayerState(tp.getName())) {
this.zone.restorePlayerState(tp);
}
this.zone.gameEndTeleport(tp);
if (this.winnersStr.contains(t.getName())) {
// give reward
for (Integer slot : t.getInventories().resolveReward().keySet()) {