Closes gh-101. Closes gh-106. Added warzone rally point that can be set with .warcfg rallypoint:warzone-name. Hp now reset when player leaves. Cleaned up battle end and game end messages.

This commit is contained in:
taoneill 2011-03-21 01:05:38 -04:00
parent d81a198feb
commit 362f625871
6 changed files with 56 additions and 44 deletions

View File

@ -1184,6 +1184,10 @@ public class War extends JavaPlugin {
//String rewardType = namedParams.get("reward"); //String rewardType = namedParams.get("reward");
inventoryToLoadout(player, this.getDefaultReward()); inventoryToLoadout(player, this.getDefaultReward());
} }
if(namedParams.containsKey("rallypoint")) {
//String rewardType = namedParams.get("reward");
setZoneRallyPoint(namedParams.get("rallypoint"), player);
}
// if(namedParams.containsKey("dropLootOnDeath")){ // if(namedParams.containsKey("dropLootOnDeath")){
// String onOff = namedParams.get("dropLootOnDeath"); // String onOff = namedParams.get("dropLootOnDeath");
// setDefaultDropLootOnDeath(onOff.equals("on") || onOff.equals("true")); // setDefaultDropLootOnDeath(onOff.equals("on") || onOff.equals("true"));
@ -1194,6 +1198,16 @@ public class War extends JavaPlugin {
} }
} }
private void setZoneRallyPoint(String warzoneName, Player player) {
Warzone zone = findWarzone(warzoneName);
if(zone == null) {
badMsg(player, "Can't set rally point. No such warzone.");
} else {
zone.setRallyPoint(player.getLocation());
WarzoneMapper.save(this, zone, false);
}
}
public Team getPlayerTeam(String playerName) { public Team getPlayerTeam(String playerName) {
for(Warzone warzone : warzones) { for(Warzone warzone : warzones) {
Team team = warzone.getPlayerTeam(playerName); Team team = warzone.getPlayerTeam(playerName);
@ -1534,7 +1548,6 @@ public class War extends JavaPlugin {
} }
public boolean getDefaultNoCreatures() { public boolean getDefaultNoCreatures() {
// TODO Auto-generated method stub
return isDefaultNoCreatures(); return isDefaultNoCreatures();
} }

View File

@ -59,7 +59,7 @@ public class Warzone {
private boolean disabled = false; private boolean disabled = false;
private boolean noCreatures; private boolean noCreatures;
private HashMap<String, InventoryStash> deadMenInventories = new HashMap<String, InventoryStash>(); private HashMap<String, InventoryStash> deadMenInventories = new HashMap<String, InventoryStash>();
private Location rallyPoint;
public Warzone(War war, World world, String name) { public Warzone(War war, World world, String name) {
this.world = world; this.world = world;
@ -867,7 +867,7 @@ public class Warzone {
int remaining = playerTeam.getRemainingLifes(); int remaining = playerTeam.getRemainingLifes();
if(remaining == 0) { // your death caused your team to lose if(remaining == 0) { // your death caused your team to lose
List<Team> teams = playerWarzone.getTeams(); List<Team> teams = playerWarzone.getTeams();
String scorers = ""; String scores = "";
for(Team t : teams) { for(Team t : teams) {
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: " t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: "
+ player.getName() + " died and there were no lives left in their life pool."); + player.getName() + " died and there were no lives left in their life pool.");
@ -876,12 +876,12 @@ public class Warzone {
// all other teams get a point // all other teams get a point
t.addPoint(); t.addPoint();
t.resetSign(); t.resetSign();
scorers += "Team " + t.getName() + " scores one point. ";
} }
scores += t.getName() + "(" + t.getPoints() + ") " ;
} }
if(!scorers.equals("")){ if(!scores.equals("")){
for(Team t : teams) { for(Team t : teams) {
t.teamcast(scorers); t.teamcast("New scores - " + scores + " (/" + getScoreCap() + ")" );
} }
} }
// detect score cap // detect score cap
@ -962,6 +962,9 @@ public class Warzone {
if(this.hasPlayerInventory(player.getName())) { if(this.hasPlayerInventory(player.getName())) {
this.restorePlayerInventory(player); this.restorePlayerInventory(player);
} }
player.setHealth(20);
player.setFireTicks(0);
player.setRemainingAir(300);
player.teleportTo(destination); player.teleportTo(destination);
war.msg(player, "Left the zone. Your inventory has (hopefully) been restored."); war.msg(player, "Left the zone. Your inventory has (hopefully) been restored.");
if(war.getWarHub() != null) { if(war.getWarHub() != null) {
@ -1038,44 +1041,11 @@ public class Warzone {
} }
public void handleScoreCapReached(Player player, String winnersStr) { public void handleScoreCapReached(Player player, String winnersStr) {
winnersStr = "Score cap reached! Winning team(s): " + winnersStr; winnersStr = "Score cap reached. Game is over! Winning team(s): " + winnersStr;
winnersStr += ". The warzone and your inventory are being reset...."; winnersStr += ". Resetting warzone and your inventory...";
// DEADMAN
// if(this.hasPlayerInventory(player.getName())){
// InventoryStash stash = inventories.remove(player.getName());
// deadMenInventories.put(player.getName(), stash);
// }
// Score cap reached. Reset everything. // Score cap reached. Reset everything.
ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr); ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr);
war.getServer().getScheduler().scheduleSyncDelayedTask(war, job); war.getServer().getScheduler().scheduleSyncDelayedTask(war, job);
// for(Team t : this.getTeams()) {
// t.teamcast(winnersStr);
// for(Player tp : t.getPlayers()) {
// PlayerInventory inv = player.getInventory();
//
// if(!tp.getName().equals(player.getName())) {
// ScoreCapReachedJob job = new ScoreCapReachedJob(tp, this);
// if(winnersStr.contains(t.getName())) {
// job.giveReward(true);
// }
// war.getServer().getScheduler().scheduleAsyncDelayedTask(war, job, 1);
//
// tp.teleportTo(this.getTeleport());
// // don't reset inv of dead guy who caused this, he's gonna die becasue this takes too long so we'll restore inv at PLAYER_MOVE
// if(this.hasPlayerInventory(tp.getName())){
// this.restorePlayerInventory(tp);
// }
// }
// if(winnersStr.contains(t.getName())) {
// // give reward
// for(Integer slot : getReward().keySet()){
// tp.getInventory().addItem(getReward().get(slot));
// }
// }
// }
// t.setPoints(0);
// t.getPlayers().clear(); // empty the team
// }
if(this.getLobby() != null) { if(this.getLobby() != null) {
this.getLobby().getVolume().resetBlocksAsJob(); this.getLobby().getVolume().resetBlocksAsJob();
} }
@ -1158,6 +1128,14 @@ public class Warzone {
} }
public void setRallyPoint(Location location) {
this.rallyPoint = location;
}
public Location getRallyPoint() {
return this.rallyPoint;
}
// public Team getTeamByName(String name) { // public Team getTeamByName(String name) {
// for(Team team : getTeams()) { // for(Team team : getTeams()) {

View File

@ -17,7 +17,6 @@ public class InitZoneJob implements Runnable {
public InitZoneJob(Warzone warzone, Player respawnExempted) { public InitZoneJob(Warzone warzone, Player respawnExempted) {
zone = warzone; zone = warzone;
this.respawnExempted = respawnExempted; this.respawnExempted = respawnExempted;
// TODO Auto-generated constructor stub
} }
public void run() { public void run() {

View File

@ -19,7 +19,9 @@ public class ScoreCapReachedJob implements Runnable {
for(Team t : zone.getTeams()) { for(Team t : zone.getTeams()) {
t.teamcast(winnersStr); t.teamcast(winnersStr);
for(Player tp : t.getPlayers()) { for(Player tp : t.getPlayers()) {
tp.teleportTo(zone.getTeleport()); // TODO: change this to a more general rally point (which will enable linking zones together) // Send everyone to rally point (or zone lobby if not rally point)
if(zone.getRallyPoint() != null) tp.teleportTo(zone.getRallyPoint());
else tp.teleportTo(zone.getTeleport());
tp.setFireTicks(0); tp.setFireTicks(0);
tp.setRemainingAir(300); tp.setRemainingAir(300);
if(zone.hasPlayerInventory(tp.getName())){ if(zone.hasPlayerInventory(tp.getName())){

View File

@ -61,7 +61,7 @@ public class WarMapper {
if(zone.getLobby() != null) { if(zone.getLobby() != null) {
zone.getLobby().getVolume().resetBlocksAsJob(); zone.getLobby().getVolume().resetBlocksAsJob();
} }
zone.initializeZoneAsJob(); // is this wise? zone.initializeZoneAsJob();
} }
} }
} }

View File

@ -221,6 +221,18 @@ public class WarzoneMapper {
// defaultNoCreatures // defaultNoCreatures
warzone.setNoCreatures(warzoneConfig.getBoolean("noCreatures")); warzone.setNoCreatures(warzoneConfig.getBoolean("noCreatures"));
// rallyPoint
String rallyPointStr = warzoneConfig.getString("rallyPoint");
if(rallyPointStr != null && !rallyPointStr.equals("")) {
String[] rallyPointStrSplit = rallyPointStr.split(",");
int rpX = Integer.parseInt(rallyPointStrSplit[0]);
int rpY = Integer.parseInt(rallyPointStrSplit[1]);
int rpZ = Integer.parseInt(rallyPointStrSplit[2]);
Location rallyPoint = new Location(world, rpX, rpY, rpZ);
warzone.setRallyPoint(rallyPoint);
}
// dropLootOnDeath // dropLootOnDeath
//warzone.setDropLootOnDeath(warzoneConfig.getBoolean("dropLootOnDeath")); //warzone.setDropLootOnDeath(warzoneConfig.getBoolean("dropLootOnDeath"));
@ -412,6 +424,14 @@ public class WarzoneMapper {
// noCreatures // noCreatures
warzoneConfig.setBoolean("noCreatures", warzone.isNoCreatures()); warzoneConfig.setBoolean("noCreatures", warzone.isNoCreatures());
// rallyPoint
String rpStr = "";
Location rp = warzone.getRallyPoint();
if(rp != null) {
rpStr = rp.getBlockX() + "," + rp.getBlockY() + "," + rp.getBlockZ();
}
warzoneConfig.setString("rallyPoint", rpStr);
// defaultDropLootOnDeath // defaultDropLootOnDeath
//warzoneConfig.setBoolean("dropLootOnDeath", warzone.isDropLootOnDeath()); //warzoneConfig.setBoolean("dropLootOnDeath", warzone.isDropLootOnDeath());