Closes gh-42. No more unfinished warzones at the warhub. Warzone files don't get deleted though.

This commit is contained in:
taoneill 2011-02-14 16:37:51 -05:00
parent 6b3d55f563
commit 03b987ee37
6 changed files with 267 additions and 372 deletions

View File

@ -63,6 +63,7 @@ public class War extends JavaPlugin {
private PluginDescriptionFile desc = null;
private final List<Warzone> warzones = new ArrayList<Warzone>();
private final List<Warzone> incompleteZones = new ArrayList<Warzone>();
private final List<String> zoneMakerNames = new ArrayList<String>();
private final List<String> zoneMakersImpersonatingPlayers = new ArrayList<String>();
private final HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
@ -705,8 +706,8 @@ public class War extends JavaPlugin {
if(warzone == null) {
// create the warzone
warzone = new Warzone(this, player.getLocation().getWorld(), arguments[0]);
this.addWarzone(warzone);
WarMapper.save(this);
this.getIncompleteZones().add(warzone);
//WarMapper.save(this);
if(arguments[1].equals("northwest") || arguments[1].equals("nw")) {
warzone.setNorthwest(player.getLocation());
this.msg(player, "Warzone " + warzone.getName() + " created. Northwesternmost point set to x:"
@ -716,7 +717,7 @@ public class War extends JavaPlugin {
this.msg(player, "Warzone " + warzone.getName() + " created. Southeasternmost point set to x:"
+ (int)warzone.getSoutheast().getBlockX() + " z:" + (int)warzone.getSoutheast().getBlockZ() + ".");
}
WarzoneMapper.save(this, warzone, false);
//WarzoneMapper.save(this, warzone, false);
} else {
// change existing warzone
if(arguments[1].equals("northwest") || arguments[1].equals("nw")) {
@ -737,6 +738,10 @@ public class War extends JavaPlugin {
int reset = warzone.getVolume().resetBlocks();
msgString = reset + " blocks reset. ";
} else {
this.addWarzone(warzone);
this.incompleteZones.remove(warzone);
WarMapper.save(this);
}
warzone.setNorthwest(player.getLocation());
if(warzone.tooSmall()) {
@ -748,6 +753,7 @@ public class War extends JavaPlugin {
msgString += "New zone outline ok. Northwesternmost point of zone " + warzone.getName() + " set to x:" + (int)warzone.getNorthwest().getBlockX()
+ " z:" + (int)warzone.getNorthwest().getBlockZ()+ ". Saving new warzone blocks...";
msg(player, msgString);
WarzoneMapper.save(this, warzone, false);
}
}
} else if(arguments[1].equals("southeast") || arguments[1].equals("se")) {
@ -768,6 +774,10 @@ public class War extends JavaPlugin {
int reset = warzone.getVolume().resetBlocks();
msgString = reset + " blocks reset. ";
} else {
this.addWarzone(warzone);
this.incompleteZones.remove(warzone);
WarMapper.save(this);
}
warzone.setSoutheast(player.getLocation());
if(warzone.tooSmall()) {
@ -779,6 +789,7 @@ public class War extends JavaPlugin {
msgString += "New zone outline ok. Southeasternmost point of zone " + warzone.getName() + " set to x:" + (int)warzone.getSoutheast().getBlockX()
+ " z:" + (int)warzone.getSoutheast().getBlockZ()+ ". Saving new warzone blocks...";
msg(player, msgString);
WarzoneMapper.save(this, warzone, false);
}
}
}
@ -1201,6 +1212,11 @@ public class War extends JavaPlugin {
return warzone;
}
}
for(Warzone warzone : incompleteZones) {
if(warzone.getName().equals(warzoneName)) {
return warzone;
}
}
return null;
}
@ -1412,4 +1428,8 @@ public class War extends JavaPlugin {
return defaultReward;
}
public List<Warzone> getIncompleteZones() {
return incompleteZones;
}
}

View File

@ -41,7 +41,7 @@ public class WarEntityListener extends EntityListener {
Team team = war.getPlayerTeam(player.getName());
if(team != null) {
Warzone zone = war.getPlayerTeamWarzone(player.getName());
handleDeath(player, zone, team);
zone.handleDeath(player);
// if(zone.isDropLootOnDeath()) {
// war.getServer().getScheduler().scheduleAsyncDelayedTask(war,
// new LootDropperTask(player.getLocation(), event.getDrops()),
@ -52,25 +52,6 @@ public class WarEntityListener extends EntityListener {
}
}
// public void onEntityDamage(EntityDamageEvent event) {
//// Entity defender = event.getEntity();
////
//// if(defender instanceof Player) {
//// Player d = (Player)defender;
//// if(event.getDamage() >= d.getHealth()) {
//// // Player died
//// Warzone defenderWarzone = war.getPlayerTeamWarzone(d.getName());
//// Team defenderTeam = war.getPlayerTeam(d.getName());
//// if(defenderTeam != null) {
////
//// handleDeath(d, defenderWarzone, defenderTeam);
//// event.setCancelled(true); // Don't let the killing blow fall down.
//// }
//// }
//// }
//
// }
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
handlerAttackDefend(event);
}
@ -190,98 +171,6 @@ public class WarEntityListener extends EntityListener {
}
}
private void handleDeath(Player player, Warzone playerWarzone, Team playerTeam) {
// teleport to team spawn upon death
war.msg(player, "You died.");
boolean newBattle = false;
boolean scoreCapReached = false;
//synchronized(playerWarzone) {
//synchronized(player) {
int remaining = playerTeam.getRemainingLifes();
if(remaining == 0) { // your death caused your team to lose
List<Team> teams = playerWarzone.getTeams();
String scorers = "";
for(Team t : teams) {
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();
scorers += "Team " + t.getName() + " scores one point. ";
}
}
if(!scorers.equals("")){
for(Team t : teams) {
t.teamcast(scorers);
}
}
// detect score cap
List<Team> scoreCapTeams = new ArrayList<Team>();
for(Team t : teams) {
if(t.getPoints() == playerWarzone.getScoreCap()) {
scoreCapTeams.add(t);
}
}
if(!scoreCapTeams.isEmpty()) {
String winnersStr = "";
for(Team winner : scoreCapTeams) {
winnersStr += winner.getName() + " ";
}
if(playerWarzone.hasPlayerInventory(player.getName())){
playerWarzone.restorePlayerInventory(player);
}
playerWarzone.handleScoreCapReached(player, winnersStr);
player.teleportTo(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
scoreCapReached = true;
} else {
// A new battle starts. Reset the zone but not the teams.
for(Team t : teams) {
t.teamcast("A new battle begins. Warzone reset.");
}
playerWarzone.getVolume().resetBlocks();
playerWarzone.initializeZone();
newBattle = true;
}
} else {
// player died without causing his team's demise
if(playerWarzone.isFlagThief(player.getName())) {
// died while carrying flag.. dropped it
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
victim.getFlagVolume().resetBlocks();
victim.initializeTeamFlag();
playerWarzone.removeThief(player.getName());
for(Team t : playerWarzone.getTeams()) {
t.teamcast(player.getName() + " died and dropped team " + victim.getName() + "'s flag.");
}
}
playerTeam.setRemainingLives(remaining - 1);
if(remaining - 1 == 0) {
for(Team t : playerWarzone.getTeams()) {
t.teamcast("Team " + playerTeam.getName() + "'s life pool is empty. One more death and they lose the battle!");
}
}
}
//}
//}
//synchronized(player) {
if(!newBattle && !scoreCapReached) {
playerTeam.resetSign();
playerWarzone.respawnPlayer(playerTeam, player);
}
// war.info(player.getName() + " died and enemy team reached score cap");
// } else if (newBattle){
// war.info(player.getName() + " died and battle ended in team " + playerTeam.getName() + "'s disfavor");
// }
//}
}
public void onEntityDamage(EntityDamageEvent event) {
if(event.getCause() == DamageCause.FIRE_TICK) {
Entity entity = event.getEntity();
@ -333,119 +222,4 @@ public class WarEntityListener extends EntityListener {
}
}
// private void handleDeath(Player player, Warzone playerWarzone, Team playerTeam) {
// // teleport to team spawn upon death
// player.sendMessage(war.str("You died."));
// boolean newBattle = false;
// boolean scoreCapReached = false;
// synchronized(playerWarzone) {
// synchronized(player) {
// int remaining = playerTeam.getRemainingTickets();
// if(remaining == 0) { // your death caused your team to lose
// List<Team> teams = playerWarzone.getTeams();
// for(Team t : teams) {
// t.teamcast(war.str("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();
// }
// }
// // detect score cap
// List<Team> scoreCapTeams = new ArrayList<Team>();
// for(Team t : teams) {
// if(t.getPoints() == playerWarzone.getScoreCap()) {
// scoreCapTeams.add(t);
// }
// }
// if(!scoreCapTeams.isEmpty()) {
// String winnersStr = "Score cap reached! Winning team(s): ";
// for(Team winner : scoreCapTeams) {
// winnersStr += winner.getName() + " ";
// }
// winnersStr += ". The warzone is being reset... Please choose a new team.";
// // Score cap reached. Reset everything.
// for(Team t : teams) {
// t.teamcast(war.str(winnersStr));
// for(Player tp : t.getPlayers()) {
// if(tp.getName() != player.getName()) {
// tp.teleportTo(playerWarzone.getTeleport());
// }
// }
// t.setPoints(0);
// t.getPlayers().clear(); // empty the team
// }
// playerWarzone.getVolume().resetBlocks();
// playerWarzone.initializeZone();
// scoreCapReached = true;
// } else {
// // We can keep going
// for(Team t : teams) {
// t.teamcast(war.str("A new battle begins. The warzone is being reset..."));
// }
// playerWarzone.getVolume().resetBlocks();
// playerWarzone.initializeZone();
// newBattle = true;
// playerTeam.setRemainingTickets(playerTeam.getRemainingTickets()); // TODO get rid of this dirty workaround for the twice move-on-death bug
// }
// } else {
// playerTeam.setRemainingTickets(remaining - 1);
// }
// }
// }
// synchronized(player) {
// if(!newBattle && !scoreCapReached) {
// playerWarzone.respawnPlayer(playerTeam, player);
// playerTeam.resetSign();
// war.info(player.getName() + " died and was tp'd back to team " + playerTeam.getName() + "'s spawn");
// } else if (scoreCapReached) {
// player.teleportTo(playerWarzone.getTeleport());
// playerTeam.resetSign();
// war.info(player.getName() + " died and enemy team reached score cap");
// } else if (newBattle){
// war.info(player.getName() + " died and battle ended in team " + playerTeam.getName() + "'s disfavor");
// }
// }
// old
// Team team = war.getPlayerTeam(player.getName());
// if(team != null){
// // teleport to team spawn upon death
// Warzone zone = war.warzone(player.getLocation());
// boolean roundOver = false;
// synchronized(zone) {
// int remaining = team.getRemainingTickets();
// if(remaining == 0) { // your death caused your team to lose
// List<Team> teams = zone.getTeams();
// for(Team t : teams) {
// t.teamcast(war.str("The battle is over. Team " + team.getName() + " lost: "
// + player.getName() + " hit the bottom of their life pool." ));
// t.teamcast(war.str("A new battle begins. The warzone is being reset..."));
// if(!t.getName().equals(team.getName())) {
// // all other teams get a point
// t.addPoint();
// t.resetSign();
// }
// }
// zone.endRound();
// zone.getVolume().resetBlocks();
// zone.initializeZone();
// roundOver = true;
// } else {
// team.setRemainingTickets(remaining - 1);
// }
// }
// if(!roundOver) {
// zone.respawnPlayer(team, player);
// player.sendMessage(war.str("You died!"));
// team.resetSign();
// war.getLogger().log(Level.INFO, player.getName() + " died and was tp'd back to team " + team.getName() + "'s spawn");
// } else {
// war.getLogger().log(Level.INFO, player.getName() + " died and battle ended in team " + team.getName() + "'s disfavor");
// }
// }
//}
}

View File

@ -133,12 +133,12 @@ public class WarPlayerListener extends PlayerListener {
noOfPlayers += t.getPlayers().size();
}
if(noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
zone.autoAssign(event, player);
Team team = zone.autoAssign(player);
event.setFrom(team.getTeamSpawn());
event.setCancelled(true);
if(war.getWarHub() != null) {
war.getWarHub().resetZoneSign(zone);
}
//zone.autoAssign(player);
//event.setCancelled(true);
} else {
event.setFrom(zone.getTeleport());
player.teleportTo(zone.getTeleport());
@ -283,11 +283,10 @@ public class WarPlayerListener extends PlayerListener {
Team team = war.getPlayerTeam(player.getName());
// Player belongs to a warzone team but is outside: he snuck out or is at spawn and died
if(locZone == null && team != null) {
handleDeath(event, player, playerWarzone, team);
if(locZone == null && team != null) {;
war.badMsg(player, "You can't sneak out of a zone while in a team. Use /leave or walk out the lobby to exit the zone, please.");
event.setFrom(team.getTeamSpawn());
//playerWarzone.respawnPlayer(team, player);
playerWarzone.handleDeath(player);
player.teleportTo(team.getTeamSpawn());
event.setCancelled(true);
return;
@ -398,95 +397,95 @@ public class WarPlayerListener extends PlayerListener {
return teamsMessage;
}
private void handleDeath(PlayerMoveEvent event, Player player, Warzone playerWarzone, Team playerTeam) {
// teleport to team spawn upon death
war.msg(player, "You died.");
boolean newBattle = false;
boolean scoreCapReached = false;
//synchronized(playerWarzone) {
//synchronized(player) {
int remaining = playerTeam.getRemainingLifes();
if(remaining == 0) { // your death caused your team to lose
List<Team> teams = playerWarzone.getTeams();
String scorers = "";
for(Team t : teams) {
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();
scorers += "Team " + t.getName() + " scores one point. ";
}
}
if(!scorers.equals("")){
for(Team t : teams) {
t.teamcast(scorers);
}
}
// detect score cap
List<Team> scoreCapTeams = new ArrayList<Team>();
for(Team t : teams) {
if(t.getPoints() == playerWarzone.getScoreCap()) {
scoreCapTeams.add(t);
}
}
if(!scoreCapTeams.isEmpty()) {
String winnersStr = "";
for(Team winner : scoreCapTeams) {
winnersStr += winner.getName() + " ";
}
if(playerWarzone.hasPlayerInventory(player.getName())){
playerWarzone.restorePlayerInventory(player);
}
playerWarzone.handleScoreCapReached(player, winnersStr);
event.setFrom(playerWarzone.getTeleport());
player.teleportTo(playerWarzone.getTeleport());
event.setCancelled(true);
scoreCapReached = true;
} else {
// A new battle starts. Reset the zone but not the teams.
for(Team t : teams) {
t.teamcast("A new battle begins. The warzone is being reset...");
}
playerWarzone.getVolume().resetBlocks();
playerWarzone.initializeZone(event);
newBattle = true;
}
} else {
// player died without causing his team's demise
if(playerWarzone.isFlagThief(player.getName())) {
// died while carrying flag.. dropped it
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
victim.getFlagVolume().resetBlocks();
victim.initializeTeamFlag();
playerWarzone.removeThief(player.getName());
for(Team t : playerWarzone.getTeams()) {
t.teamcast(player.getName() + " died and dropped team " + victim.getName() + "'s flag.");
}
}
playerTeam.setRemainingLives(remaining - 1);
if(remaining - 1 == 0) {
for(Team t : playerWarzone.getTeams()) {
t.teamcast("Team " + t.getName() + "'s life pool is empty. One more death and they lose the battle!");
}
}
}
//}
//}
//synchronized(player) {
if(!newBattle && !scoreCapReached) {
playerTeam.resetSign();
playerWarzone.respawnPlayer(event, playerTeam, player);
}
// else if (scoreCapReached) {
// private void handleDeath(PlayerMoveEvent event, Player player, Warzone playerWarzone, Team playerTeam) {
// // teleport to team spawn upon death
// war.msg(player, "You died.");
// boolean newBattle = false;
// boolean scoreCapReached = false;
// //synchronized(playerWarzone) {
// //synchronized(player) {
// int remaining = playerTeam.getRemainingLifes();
// if(remaining == 0) { // your death caused your team to lose
// List<Team> teams = playerWarzone.getTeams();
// String scorers = "";
// for(Team t : teams) {
// t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: "
// + player.getName() + " died and there were no lives left in their life pool." );
//
// war.info(player.getName() + " died and enemy team reached score cap");
// } else if (newBattle){
// war.info(player.getName() + " died and battle ended in team " + playerTeam.getName() + "'s disfavor");
// if(!t.getName().equals(playerTeam.getName())) {
// // all other teams get a point
// t.addPoint();
// t.resetSign();
// scorers += "Team " + t.getName() + " scores one point. ";
// }
// }
// if(!scorers.equals("")){
// for(Team t : teams) {
// t.teamcast(scorers);
// }
// }
// // detect score cap
// List<Team> scoreCapTeams = new ArrayList<Team>();
// for(Team t : teams) {
// if(t.getPoints() == playerWarzone.getScoreCap()) {
// scoreCapTeams.add(t);
// }
// }
// if(!scoreCapTeams.isEmpty()) {
// String winnersStr = "";
// for(Team winner : scoreCapTeams) {
// winnersStr += winner.getName() + " ";
// }
// if(playerWarzone.hasPlayerInventory(player.getName())){
// playerWarzone.restorePlayerInventory(player);
// }
//
// playerWarzone.handleScoreCapReached(player, winnersStr);
// event.setFrom(playerWarzone.getTeleport());
// player.teleportTo(playerWarzone.getTeleport());
// event.setCancelled(true);
// scoreCapReached = true;
// } else {
// // A new battle starts. Reset the zone but not the teams.
// for(Team t : teams) {
// t.teamcast("A new battle begins. The warzone is being reset...");
// }
// playerWarzone.getVolume().resetBlocks();
// playerWarzone.initializeZone(event);
// newBattle = true;
// }
// } else {
// // player died without causing his team's demise
// if(playerWarzone.isFlagThief(player.getName())) {
// // died while carrying flag.. dropped it
// Team victim = playerWarzone.getVictimTeamForThief(player.getName());
// victim.getFlagVolume().resetBlocks();
// victim.initializeTeamFlag();
// playerWarzone.removeThief(player.getName());
// for(Team t : playerWarzone.getTeams()) {
// t.teamcast(player.getName() + " died and dropped team " + victim.getName() + "'s flag.");
// }
// }
// playerTeam.setRemainingLives(remaining - 1);
// if(remaining - 1 == 0) {
// for(Team t : playerWarzone.getTeams()) {
// t.teamcast("Team " + t.getName() + "'s life pool is empty. One more death and they lose the battle!");
// }
// }
// }
// //}
// //}
// //synchronized(player) {
// if(!newBattle && !scoreCapReached) {
// playerTeam.resetSign();
// playerWarzone.respawnPlayer(event, playerTeam, player);
// }
//// else if (scoreCapReached) {
////
//// war.info(player.getName() + " died and enemy team reached score cap");
//// } else if (newBattle){
//// war.info(player.getName() + " died and battle ended in team " + playerTeam.getName() + "'s disfavor");
//// }
// //}
// }
//}
}
}

View File

@ -240,26 +240,26 @@ public class Warzone {
}
}
public void initializeZone(PlayerMoveEvent event) {
if(ready() && volume.isSaved()){
// everyone back to team spawn with full health
for(Team team : teams) {
for(Player p : team.getPlayers()) {
if(p.getName().equals(event.getPlayer().getName())) {
respawnPlayer(event, team, event.getPlayer());
} else {
respawnPlayer(team, p);
}
}
team.setRemainingLives(lifePool);
team.setTeamSpawn(team.getTeamSpawn());
if(team.getTeamFlag() != null) team.setTeamFlag(team.getTeamFlag());
team.resetSign();
}
initZone();
}
}
// public void initializeZone(PlayerMoveEvent event) {
// if(ready() && volume.isSaved()){
// // everyone back to team spawn with full health
// for(Team team : teams) {
// for(Player p : team.getPlayers()) {
// if(p.getName().equals(event.getPlayer().getName())) {
// respawnPlayer(event, team, event.getPlayer());
// } else {
// respawnPlayer(team, p);
// }
// }
// team.setRemainingLives(lifePool);
// team.setTeamSpawn(team.getTeamSpawn());
// if(team.getTeamFlag() != null) team.setTeamFlag(team.getTeamFlag());
// team.resetSign();
// }
//
// initZone();
// }
// }
private void initZone() {
// add wall outlines
@ -783,29 +783,29 @@ public class Warzone {
return lobby;
}
public void autoAssign(PlayerMoveEvent event, Player player) {
Team lowestNoOfPlayers = null;
for(Team t : teams) {
if(lowestNoOfPlayers == null
|| (lowestNoOfPlayers != null && lowestNoOfPlayers.getPlayers().size() > t.getPlayers().size())) {
lowestNoOfPlayers = t;
}
}
if(lowestNoOfPlayers != null) {
lowestNoOfPlayers.addPlayer(player);
lowestNoOfPlayers.resetSign();
if(!hasPlayerInventory(player.getName())) {
keepPlayerInventory(player);
}
war.msg(player, "Your inventory is is storage until you /leave.");
respawnPlayer(event, lowestNoOfPlayers, player);
for(Team team : teams){
team.teamcast("" + player.getName() + " joined team " + lowestNoOfPlayers.getName() + ".");
}
}
}
// public void autoAssign(PlayerMoveEvent event, Player player) {
// Team lowestNoOfPlayers = null;
// for(Team t : teams) {
// if(lowestNoOfPlayers == null
// || (lowestNoOfPlayers != null && lowestNoOfPlayers.getPlayers().size() > t.getPlayers().size())) {
// lowestNoOfPlayers = t;
// }
// }
// if(lowestNoOfPlayers != null) {
// lowestNoOfPlayers.addPlayer(player);
// lowestNoOfPlayers.resetSign();
// if(!hasPlayerInventory(player.getName())) {
// keepPlayerInventory(player);
// }
// war.msg(player, "Your inventory is is storage until you /leave.");
// respawnPlayer(event, lowestNoOfPlayers, player);
// for(Team team : teams){
// team.teamcast("" + player.getName() + " joined team " + lowestNoOfPlayers.getName() + ".");
// }
// }
// }
public void autoAssign(Player player) {
public Team autoAssign(Player player) {
Team lowestNoOfPlayers = null;
for(Team t : teams) {
if(lowestNoOfPlayers == null
@ -825,6 +825,7 @@ public class Warzone {
team.teamcast("" + player.getName() + " joined team " + team.getName() + ".");
}
}
return lowestNoOfPlayers;
}
public void setTeamCap(int teamCap) {
@ -859,6 +860,102 @@ public class Warzone {
return drawZoneOutline;
}
public void handleDeath(Player player) {
Team playerTeam = war.getPlayerTeam(player.getName());
Warzone playerWarzone = war.getPlayerTeamWarzone(player.getName());
if(playerTeam != null && playerWarzone != null) {
// teleport to team spawn upon death
war.msg(player, "You died.");
boolean newBattle = false;
boolean scoreCapReached = false;
//synchronized(playerWarzone) {
//synchronized(player) {
int remaining = playerTeam.getRemainingLifes();
if(remaining == 0) { // your death caused your team to lose
List<Team> teams = playerWarzone.getTeams();
String scorers = "";
for(Team t : teams) {
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();
scorers += "Team " + t.getName() + " scores one point. ";
}
}
if(!scorers.equals("")){
for(Team t : teams) {
t.teamcast(scorers);
}
}
// detect score cap
List<Team> scoreCapTeams = new ArrayList<Team>();
for(Team t : teams) {
if(t.getPoints() == playerWarzone.getScoreCap()) {
scoreCapTeams.add(t);
}
}
if(!scoreCapTeams.isEmpty()) {
String winnersStr = "";
for(Team winner : scoreCapTeams) {
winnersStr += winner.getName() + " ";
}
if(playerWarzone.hasPlayerInventory(player.getName())){
playerWarzone.restorePlayerInventory(player);
}
playerWarzone.handleScoreCapReached(player, winnersStr);
player.teleportTo(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
scoreCapReached = true;
} else {
// A new battle starts. Reset the zone but not the teams.
for(Team t : teams) {
t.teamcast("A new battle begins. Warzone reset.");
}
playerWarzone.getVolume().resetBlocks();
playerWarzone.initializeZone();
newBattle = true;
}
} else {
// player died without causing his team's demise
if(playerWarzone.isFlagThief(player.getName())) {
// died while carrying flag.. dropped it
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
victim.getFlagVolume().resetBlocks();
victim.initializeTeamFlag();
playerWarzone.removeThief(player.getName());
for(Team t : playerWarzone.getTeams()) {
t.teamcast(player.getName() + " died and dropped team " + victim.getName() + "'s flag.");
}
}
playerTeam.setRemainingLives(remaining - 1);
if(remaining - 1 == 0) {
for(Team t : playerWarzone.getTeams()) {
t.teamcast("Team " + playerTeam.getName() + "'s life pool is empty. One more death and they lose the battle!");
}
}
}
//}
//}
//synchronized(player) {
if(!newBattle && !scoreCapReached) {
playerTeam.resetSign();
playerWarzone.respawnPlayer(playerTeam, player);
}
// war.info(player.getName() + " died and enemy team reached score cap");
// } else if (newBattle){
// war.info(player.getName() + " died and battle ended in team " + playerTeam.getName() + "'s disfavor");
// }
//}
}
}
public void handlePlayerLeave(Player player, Location destination) {
Team playerTeam = war.getPlayerTeam(player.getName());
if(playerTeam !=null) {

View File

@ -42,6 +42,7 @@ public class ZoneLobby {
public ZoneLobby(War war, Warzone warzone, BlockFace wall) {
this.war = war;
this.warzone = warzone;
//this.changeWall(wall, false);
this.changeWall(wall);
}
@ -68,6 +69,10 @@ public class ZoneLobby {
}
public void changeWall(BlockFace newWall) {
// changeWall(newWall, true);
// }
//
// public void changeWall(BlockFace newWall, boolean save) {
if(volume == null) {
// no previous wall
this.volume = new Volume("lobby", war, warzone.getWorld());
@ -128,7 +133,7 @@ public class ZoneLobby {
corner2 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z + lobbyDepth);
}
if(corner1 != null && corner2 != null) {
if(corner1 != null && corner2 != null/* && save*/) {
// save the blocks, wide enough for three team gates, 3+1 high and 10 deep, extruding out from the zone wall.
this.volume.setCornerOne(corner1);
this.volume.setCornerTwo(corner2);
@ -141,7 +146,7 @@ public class ZoneLobby {
// maybe the number of teams change, now reset the gate positions
setGatePositions(lobbyMiddleWallBlock);
if(lobbyMiddleWallBlock != null && volume != null && volume.isSaved()) {
if(lobbyMiddleWallBlock != null && volume != null /*&& volume.isSaved()*/) {
// flatten the area (set all but floor to air, then replace any floor air blocks with glass)
this.volume.clearBlocksThatDontFloat();
this.volume.setToMaterial(Material.AIR);

View File

@ -154,7 +154,7 @@ public class VolumeMapper {
}
public static void save(Volume volume, String zoneName, War war) {
if(volume.isSaved() && volume.getBlockTypes() != null) {
if(volume.hasTwoCorners()) {
BufferedWriter out = null;
try {
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));