mirror of
https://github.com/taoneill/war.git
synced 2025-01-07 16:27:44 +01:00
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:
parent
95308c8bc9
commit
1b9f06e3ca
@ -193,11 +193,11 @@ public class WarEntityListener extends EntityListener {
|
|||||||
if (!War.war.isLoaded()) {
|
if (!War.war.isLoaded()) {
|
||||||
return;
|
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> explodedBlocks = event.blockList();
|
||||||
List<Block> dontExplode = new ArrayList<Block>();
|
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 (!explosionInAWarzone && War.war.isTntInZonesOnly() && event.getEntity() instanceof TNTPrimed) {
|
||||||
// if tntinzonesonly:true, no tnt blows up outside zones
|
// if tntinzonesonly:true, no tnt blows up outside zones
|
||||||
|
@ -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
|
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
|
&& this.random.nextInt(7) == 3) { // one chance out of many of getting healed
|
||||||
int currentHp = player.getHealth();
|
int currentHp = player.getHealth();
|
||||||
int newHp = Math.max(20, currentHp + locZone.getMonumentHeal());
|
int newHp = Math.min(20, currentHp + locZone.getMonumentHeal());
|
||||||
|
|
||||||
player.setHealth(newHp);
|
player.setHealth(newHp);
|
||||||
String isS = "s";
|
String isS = "s";
|
||||||
|
@ -41,22 +41,27 @@ public class SetTeamCommand extends AbstractZoneMakerCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TeamKind teamKind = TeamKind.teamKindFromString(this.args[0]);
|
TeamKind teamKind = TeamKind.teamKindFromString(this.args[0]);
|
||||||
Team existingTeam = zone.getTeamByKind(teamKind);
|
|
||||||
if (existingTeam != null) {
|
if (teamKind == null) {
|
||||||
// relocate
|
return false;
|
||||||
existingTeam.setTeamSpawn(player.getLocation());
|
|
||||||
this.msg("Team " + existingTeam.getName() + " spawn relocated.");
|
|
||||||
} else {
|
} else {
|
||||||
// new team (use default TeamKind name for now)
|
Team existingTeam = zone.getTeamByKind(teamKind);
|
||||||
Team newTeam = new Team(teamKind.toString(), teamKind, player.getLocation(), zone);
|
if (existingTeam != null) {
|
||||||
newTeam.setRemainingLives(zone.getLifePool());
|
// relocate
|
||||||
zone.getTeams().add(newTeam);
|
existingTeam.setTeamSpawn(player.getLocation());
|
||||||
if (zone.getLobby() != null) {
|
this.msg("Team " + existingTeam.getName() + " spawn relocated.");
|
||||||
zone.getLobby().getVolume().resetBlocks();
|
} else {
|
||||||
zone.getLobby().initialize();
|
// 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);
|
WarzoneMapper.save(zone, false);
|
||||||
|
@ -45,7 +45,7 @@ public class SetZoneLobbyCommand extends AbstractZoneMakerCommand {
|
|||||||
Warzone givenWarzone = Warzone.getZoneByName(this.args[0]);
|
Warzone givenWarzone = Warzone.getZoneByName(this.args[0]);
|
||||||
if (givenWarzone == null) {
|
if (givenWarzone == null) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!this.isSenderAuthorOfZone(zone)) {
|
} else if (!this.isSenderAuthorOfZone(givenWarzone)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Move the warzone lobby
|
// Move the warzone lobby
|
||||||
|
@ -991,13 +991,10 @@ public class Warzone {
|
|||||||
// Score cap reached. Reset everything.
|
// Score cap reached. Reset everything.
|
||||||
ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr);
|
ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr);
|
||||||
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
||||||
if (this.getLobby() != null) {
|
|
||||||
this.getLobby().getVolume().resetBlocksAsJob();
|
|
||||||
}
|
|
||||||
this.getVolume().resetBlocksAsJob();
|
this.getVolume().resetBlocksAsJob();
|
||||||
this.initializeZoneAsJob(player);
|
this.initializeZoneAsJob(player);
|
||||||
if (War.war.getWarHub() != null) {
|
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);
|
War.war.getWarHub().resetZoneSign(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user