diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 4d5307a..51bfe3b 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -1184,6 +1184,10 @@ public class War extends JavaPlugin { //String rewardType = namedParams.get("reward"); inventoryToLoadout(player, this.getDefaultReward()); } + if(namedParams.containsKey("rallypoint")) { + //String rewardType = namedParams.get("reward"); + setZoneRallyPoint(namedParams.get("rallypoint"), player); + } // if(namedParams.containsKey("dropLootOnDeath")){ // String onOff = namedParams.get("dropLootOnDeath"); // 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) { for(Warzone warzone : warzones) { Team team = warzone.getPlayerTeam(playerName); @@ -1534,7 +1548,6 @@ public class War extends JavaPlugin { } public boolean getDefaultNoCreatures() { - // TODO Auto-generated method stub return isDefaultNoCreatures(); } diff --git a/war/src/main/java/com/tommytony/war/Warzone.java b/war/src/main/java/com/tommytony/war/Warzone.java index 455de2c..0f7d18f 100644 --- a/war/src/main/java/com/tommytony/war/Warzone.java +++ b/war/src/main/java/com/tommytony/war/Warzone.java @@ -59,7 +59,7 @@ public class Warzone { private boolean disabled = false; private boolean noCreatures; private HashMap deadMenInventories = new HashMap(); - + private Location rallyPoint; public Warzone(War war, World world, String name) { this.world = world; @@ -867,7 +867,7 @@ public class Warzone { int remaining = playerTeam.getRemainingLifes(); if(remaining == 0) { // your death caused your team to lose List teams = playerWarzone.getTeams(); - String scorers = ""; + String scores = ""; 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."); @@ -876,12 +876,12 @@ public class Warzone { // all other teams get a point t.addPoint(); t.resetSign(); - scorers += "Team " + t.getName() + " scores one point. "; } + scores += t.getName() + "(" + t.getPoints() + ") " ; } - if(!scorers.equals("")){ + if(!scores.equals("")){ for(Team t : teams) { - t.teamcast(scorers); + t.teamcast("New scores - " + scores + " (/" + getScoreCap() + ")" ); } } // detect score cap @@ -962,6 +962,9 @@ public class Warzone { if(this.hasPlayerInventory(player.getName())) { this.restorePlayerInventory(player); } + player.setHealth(20); + player.setFireTicks(0); + player.setRemainingAir(300); player.teleportTo(destination); war.msg(player, "Left the zone. Your inventory has (hopefully) been restored."); if(war.getWarHub() != null) { @@ -1038,44 +1041,11 @@ public class Warzone { } public void handleScoreCapReached(Player player, String winnersStr) { - winnersStr = "Score cap reached! Winning team(s): " + winnersStr; - winnersStr += ". The warzone and your inventory are being reset...."; -// DEADMAN -// if(this.hasPlayerInventory(player.getName())){ -// InventoryStash stash = inventories.remove(player.getName()); -// deadMenInventories.put(player.getName(), stash); -// } + winnersStr = "Score cap reached. Game is over! Winning team(s): " + winnersStr; + winnersStr += ". Resetting warzone and your inventory..."; // Score cap reached. Reset everything. ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr); 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) { 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) { // for(Team team : getTeams()) { diff --git a/war/src/main/java/com/tommytony/war/jobs/InitZoneJob.java b/war/src/main/java/com/tommytony/war/jobs/InitZoneJob.java index bf77548..a39b856 100644 --- a/war/src/main/java/com/tommytony/war/jobs/InitZoneJob.java +++ b/war/src/main/java/com/tommytony/war/jobs/InitZoneJob.java @@ -17,7 +17,6 @@ public class InitZoneJob implements Runnable { public InitZoneJob(Warzone warzone, Player respawnExempted) { zone = warzone; this.respawnExempted = respawnExempted; - // TODO Auto-generated constructor stub } public void run() { diff --git a/war/src/main/java/com/tommytony/war/jobs/ScoreCapReachedJob.java b/war/src/main/java/com/tommytony/war/jobs/ScoreCapReachedJob.java index b63938f..5f5d087 100644 --- a/war/src/main/java/com/tommytony/war/jobs/ScoreCapReachedJob.java +++ b/war/src/main/java/com/tommytony/war/jobs/ScoreCapReachedJob.java @@ -19,7 +19,9 @@ public class ScoreCapReachedJob implements Runnable { for(Team t : zone.getTeams()) { t.teamcast(winnersStr); 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.setRemainingAir(300); if(zone.hasPlayerInventory(tp.getName())){ diff --git a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java index 8a18b63..7c0bb9a 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarMapper.java @@ -61,7 +61,7 @@ public class WarMapper { if(zone.getLobby() != null) { zone.getLobby().getVolume().resetBlocksAsJob(); } - zone.initializeZoneAsJob(); // is this wise? + zone.initializeZoneAsJob(); } } } diff --git a/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java b/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java index 1528f09..746e868 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java @@ -221,6 +221,18 @@ public class WarzoneMapper { // defaultNoCreatures 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 //warzone.setDropLootOnDeath(warzoneConfig.getBoolean("dropLootOnDeath")); @@ -412,6 +424,14 @@ public class WarzoneMapper { // noCreatures 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 //warzoneConfig.setBoolean("dropLootOnDeath", warzone.isDropLootOnDeath());