From 04b917807cf6b204fec3d2b8a8a67b45c901a5a8 Mon Sep 17 00:00:00 2001 From: taoneill Date: Sun, 15 May 2011 11:35:08 -0400 Subject: [PATCH] Closes gh-97. Closes gh-171. Closes gh-108. Closes gh-85. Closes gh-67. Zonemakers see magic walls when on a team, which should work instead of forcing zonemakers to use /zonemaker to enable zonemaker mode. Friendly fire setting should now get persisted properly. When a bouncing arrow hits you you shouldn't get a friendly fire message anymore. No scoring can occur if other teams are empty. --- .../main/java/bukkit/tommytony/war/War.java | 4 ++-- .../bukkit/tommytony/war/WarBlockListener.java | 2 +- .../tommytony/war/WarEntityListener.java | 5 ++--- .../tommytony/war/WarPlayerListener.java | 3 ++- war/src/main/java/com/tommytony/war/Team.java | 18 +++++++++++++++--- .../main/java/com/tommytony/war/Warzone.java | 2 +- .../tommytony/war/jobs/ScoreCapReachedJob.java | 2 +- .../tommytony/war/mappers/WarzoneMapper.java | 2 +- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index d617db3..1708a6e 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -582,7 +582,7 @@ public class War extends JavaPlugin { p.teleport(warzone.getTeleport()); this.msg(player, "You have left the warzone. Your inventory has (hopefully) been restored."); } - team.setPoints(0); + team.resetPoints(); team.getPlayers().clear(); } @@ -1235,7 +1235,7 @@ public class War extends JavaPlugin { wandBearers.put(player.getName(), zoneName); player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD, 1, (byte) 8)); //player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.WOOD_SWORD)); - this.msg(player, "You now have a wand for zone " + zoneName + ". Left-click for corner 1. Right-click for corner 2."); + this.msg(player, "You now have a wand for zone " + zoneName + ". Left-click with wodden sword for corner 1. Right-click for corner 2."); } } } diff --git a/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java b/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java index d408df4..c577e05 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarBlockListener.java @@ -185,7 +185,7 @@ public class WarBlockListener extends BlockListener { } 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."); + war.msg(player, "You can't steal team " + lostFlagTeam.getName() + "'s flag since no players are on that team."); } } event.setCancelled(true); diff --git a/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java b/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java index c315d89..69f9d77 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarEntityListener.java @@ -105,6 +105,8 @@ public class WarEntityListener extends EntityListener { "in the other teams in that warzone."); } else if (defenderTeam == null) { war.badMsg(a, "Your target is not in a team."); + } else if (attacker != null && defender != null && attacker.getEntityId() == defender.getEntityId()) { + // You just hit yourself, probably with a bouncing arrow } else if (attackerTeam == defenderTeam) { war.badMsg(a, "Your target is on your team."); } else if (attackerWarzone != defenderWarzone) { @@ -113,9 +115,6 @@ public class WarEntityListener extends EntityListener { event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team } -// if(event.isCancelled() && event instanceof EntityDamageByProjectileEvent) { -// //((EntityDamageByProjectileEvent)event).setBounce(true); -// } } else if (defender instanceof Player && event instanceof EntityDamageByProjectileEvent) { // attacked by dispenser arrow most probably // Detect death, prevent it and respawn the player diff --git a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java index cc43560..c748126 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java +++ b/war/src/main/java/bukkit/tommytony/war/WarPlayerListener.java @@ -261,7 +261,8 @@ public class WarPlayerListener extends PlayerListener { // Zone walls Warzone nearbyZone = war.zoneOfZoneWallAtProximity(playerLoc); - if(nearbyZone != null && !isMaker) { // zone makers don't get bothered with guard walls + Team currentTeam = war.getPlayerTeam(player.getName()); + if(nearbyZone != null && (!isMaker || (isMaker && currentTeam != null))) { // zone makers don't get bothered with guard walls nearbyZone.protectZoneWallAgainstPlayer(player); } else { // zone makers still need to delete their walls // make sure to delete any wall guards as you leave diff --git a/war/src/main/java/com/tommytony/war/Team.java b/war/src/main/java/com/tommytony/war/Team.java index 97fd8e8..a90a8b0 100644 --- a/war/src/main/java/com/tommytony/war/Team.java +++ b/war/src/main/java/com/tommytony/war/Team.java @@ -349,7 +349,19 @@ public class Team { } public void addPoint() { - if (players.size()!=0) points++; + boolean atLeastOnePlayerOnTeam = players.size() != 0; + boolean atLeastOnePlayerOnOtherTeam = false; + for(Team team : warzone.getTeams()) { + if(!team.getName().equals(this.getName()) + && team.getPlayers().size() > 0) { + atLeastOnePlayerOnOtherTeam = true; + } + } + if (atLeastOnePlayerOnTeam && atLeastOnePlayerOnOtherTeam) { + points++; + } else if (!atLeastOnePlayerOnOtherTeam) { + this.teamcast("Can't score until at least one player joins another team."); + } } public int getPoints() { @@ -402,8 +414,8 @@ public class Team { this.spawnVolume = volume; } - public void setPoints(int score) { - if (players.size()!=0) this.points = score; + public void resetPoints() { + this.points = 0; } public void setFlagVolume(Volume flagVolume) { diff --git a/war/src/main/java/com/tommytony/war/Warzone.java b/war/src/main/java/com/tommytony/war/Warzone.java index 65bd9d5..cdb3930 100644 --- a/war/src/main/java/com/tommytony/war/Warzone.java +++ b/war/src/main/java/com/tommytony/war/Warzone.java @@ -932,7 +932,7 @@ public class Warzone { if(zoneEmpty) { // reset the zone for a new game when the last player leaves for(Team team : this.getTeams()) { - team.setPoints(0); + team.resetPoints(); team.setRemainingLives(this.getLifePool()); } this.getVolume().resetBlocksAsJob(); 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 36bc907..9bf1699 100644 --- a/war/src/main/java/com/tommytony/war/jobs/ScoreCapReachedJob.java +++ b/war/src/main/java/com/tommytony/war/jobs/ScoreCapReachedJob.java @@ -38,7 +38,7 @@ public class ScoreCapReachedJob implements Runnable { } } } - t.setPoints(0); + t.resetPoints(); t.getPlayers().clear(); // empty the team } } 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 6365d82..b9c8f8f 100644 --- a/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java +++ b/war/src/main/java/com/tommytony/war/mappers/WarzoneMapper.java @@ -338,7 +338,7 @@ public class WarzoneMapper { warzoneConfig.setString("teamFlags", teamFlagsStr); // ff - warzoneConfig.setBoolean("firendlyFire", warzone.getFriendlyFire()); + warzoneConfig.setBoolean("friendlyFire", warzone.getFriendlyFire()); // loadout String loadoutStr = "";