Closes gh-300. Closes gh-314. Fixed NPE in explosion handling. Lobby doesn't flash at game end anymore (no more dropping to the ground). Meddled with monument healing - it's still wonky although at least it wont give max hp all the time anymore. Added error handling of bad team name.

This commit is contained in:
taoneill 2011-12-06 20:58:33 -05:00
parent 95308c8bc9
commit 1b9f06e3ca
5 changed files with 24 additions and 22 deletions

View File

@ -193,11 +193,11 @@ public class WarEntityListener extends EntityListener {
if (!War.war.isLoaded()) {
return;
}
// protect zones elements, lobbies and warhub from creepers
// protect zones elements, lobbies and warhub from creepers and tnt
List<Block> explodedBlocks = event.blockList();
List<Block> dontExplode = new ArrayList<Block>();
boolean explosionInAWarzone = Warzone.getZoneByLocation(event.getEntity().getLocation()) != null;
boolean explosionInAWarzone = event.getEntity() != null && Warzone.getZoneByLocation(event.getEntity().getLocation()) != null;
if (!explosionInAWarzone && War.war.isTntInZonesOnly() && event.getEntity() instanceof TNTPrimed) {
// if tntinzonesonly:true, no tnt blows up outside zones

View File

@ -439,7 +439,7 @@ public class WarPlayerListener extends PlayerListener {
if (playerTeam != null && playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam) && player.getHealth() < 20 && player.getHealth() > 0 // don't heal the dead
&& this.random.nextInt(7) == 3) { // one chance out of many of getting healed
int currentHp = player.getHealth();
int newHp = Math.max(20, currentHp + locZone.getMonumentHeal());
int newHp = Math.min(20, currentHp + locZone.getMonumentHeal());
player.setHealth(newHp);
String isS = "s";

View File

@ -41,22 +41,27 @@ public class SetTeamCommand extends AbstractZoneMakerCommand {
}
TeamKind teamKind = TeamKind.teamKindFromString(this.args[0]);
Team existingTeam = zone.getTeamByKind(teamKind);
if (existingTeam != null) {
// relocate
existingTeam.setTeamSpawn(player.getLocation());
this.msg("Team " + existingTeam.getName() + " spawn relocated.");
if (teamKind == null) {
return false;
} else {
// new team (use default TeamKind name for now)
Team newTeam = new Team(teamKind.toString(), teamKind, player.getLocation(), zone);
newTeam.setRemainingLives(zone.getLifePool());
zone.getTeams().add(newTeam);
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();
zone.getLobby().initialize();
Team existingTeam = zone.getTeamByKind(teamKind);
if (existingTeam != null) {
// relocate
existingTeam.setTeamSpawn(player.getLocation());
this.msg("Team " + existingTeam.getName() + " spawn relocated.");
} else {
// new team (use default TeamKind name for now)
Team newTeam = new Team(teamKind.toString(), teamKind, player.getLocation(), zone);
newTeam.setRemainingLives(zone.getLifePool());
zone.getTeams().add(newTeam);
if (zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocks();
zone.getLobby().initialize();
}
newTeam.setTeamSpawn(player.getLocation());
this.msg("Team " + newTeam.getName() + " created with spawn here.");
}
newTeam.setTeamSpawn(player.getLocation());
this.msg("Team " + newTeam.getName() + " created with spawn here.");
}
WarzoneMapper.save(zone, false);

View File

@ -45,7 +45,7 @@ public class SetZoneLobbyCommand extends AbstractZoneMakerCommand {
Warzone givenWarzone = Warzone.getZoneByName(this.args[0]);
if (givenWarzone == null) {
return false;
} else if (!this.isSenderAuthorOfZone(zone)) {
} else if (!this.isSenderAuthorOfZone(givenWarzone)) {
return true;
} else {
// Move the warzone lobby

View File

@ -991,13 +991,10 @@ public class Warzone {
// Score cap reached. Reset everything.
ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr);
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
if (this.getLobby() != null) {
this.getLobby().getVolume().resetBlocksAsJob();
}
this.getVolume().resetBlocksAsJob();
this.initializeZoneAsJob(player);
if (War.war.getWarHub() != null) {
// TODO: test if warhub sign give the correct info despite the jobs
// TODO: test if warhub sign gives the correct info despite the jobs
War.war.getWarHub().resetZoneSign(this);
}
}