Teams without any players won't get listed in the scoring, can't steal flags from teams without players

This commit is contained in:
Superyoshi 2011-04-05 15:15:01 +02:00
parent 55ac717f89
commit 3032c6a0fc
2 changed files with 35 additions and 19 deletions

View File

@ -170,21 +170,25 @@ public class WarBlockListener extends BlockListener {
// detect audacious thieves
war.badMsg(player, "You can only steal one flag at a time!");
} else {
// player just broke the flag block of other team: cancel to avoid drop, give player the block, set block to air
Team lostFlagTeam = warzone.getTeamForFlagBlock(block);
ItemStack teamKindBlock = new ItemStack(lostFlagTeam.getKind().getMaterial(), 1, (short)1, new Byte(lostFlagTeam.getKind().getData()));
player.getInventory().clear();
player.getInventory().addItem(teamKindBlock);
warzone.addFlagThief(lostFlagTeam, player.getName());
block.setType(Material.AIR);
for(Team t : warzone.getTeams()) {
t.teamcast(player.getName() + " stole team " + lostFlagTeam.getName() + "'s flag.");
if(t.getName().equals(lostFlagTeam.getName())){
t.teamcast("Prevent " + player.getName() + " from reaching team " + team.getName() + "'s spawn or flag.");
if (lostFlagTeam.getPlayers().size() != 0) {
// player just broke the flag block of other team: cancel to avoid drop, give player the block, set block to air
ItemStack teamKindBlock = new ItemStack(lostFlagTeam.getKind().getMaterial(), 1, (short)1, new Byte(lostFlagTeam.getKind().getData()));
player.getInventory().clear();
player.getInventory().addItem(teamKindBlock);
warzone.addFlagThief(lostFlagTeam, player.getName());
block.setType(Material.AIR);
for(Team t : warzone.getTeams()) {
t.teamcast(player.getName() + " stole team " + lostFlagTeam.getName() + "'s flag.");
if(t.getName().equals(lostFlagTeam.getName())){
t.teamcast("Prevent " + player.getName() + " from reaching team " + team.getName() + "'s spawn or flag.");
}
}
}
war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn or flag to capture it!");
war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn or flag to capture it!");
} else {
war.msg(player, "You can't steal team " + lostFlagTeam.getName() + "'s flag since there are no players there.");
}
}
event.setCancelled(true);
return;

View File

@ -44,6 +44,7 @@ public class Warzone {
private boolean drawZoneOutline;
private int teamCap = 5;
private int scoreCap = 5;
private int monumentHeal = 5;
private String spawnStyle = TeamSpawnStyles.BIG;
private HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
@ -74,6 +75,7 @@ public class Warzone {
this.setAutoAssignOnly(war.getDefaultAutoAssignOnly());
this.teamCap = war.getDefaultTeamCap();
this.scoreCap = war.getDefaultScoreCap();
this.monumentHeal = war.getDefaultMonumentHeal();
this.setBlockHeads(war.isDefaultBlockHeads());
this.setDropLootOnDeath(war.isDefaultDropLootOnDeath());
this.setUnbreakableZoneBlocks(war.isDefaultUnbreakableZoneBlocks());
@ -472,6 +474,14 @@ public class Warzone {
public int getLifePool() {
return lifePool;
}
public void setMonumentHeal(int monumentHeal) { //SY
this.monumentHeal = monumentHeal;
}
public int getMonumentHeal() { //SY
return monumentHeal;
}
public void setFriendlyFire(boolean ffOn) {
this.friendlyFire = ffOn;
@ -865,12 +875,14 @@ public class Warzone {
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.getName().equals(playerTeam.getName())) {
// all other teams get a point
t.addPoint();
t.resetSign();
if (t.getPlayers().size() != 0) {
if(!t.getName().equals(playerTeam.getName())) {
// all other teams get a point
t.addPoint();
t.resetSign();
}
scores += t.getName() + "(" + t.getPoints() + ") " ;
}
scores += t.getName() + "(" + t.getPoints() + ") " ;
}
if(!scores.equals("")){
for(Team t : teams) {
@ -887,7 +899,7 @@ public class Warzone {
if(!scoreCapTeams.isEmpty()) {
String winnersStr = "";
for(Team winner : scoreCapTeams) {
winnersStr += winner.getName() + " ";
if (winner.getPlayers().size() != 0) winnersStr += winner.getName() + " ";
}
playerWarzone.handleScoreCapReached(player, winnersStr);