From 41b84280c890ca66ca61f11f3b6958f09faedab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 16 Jul 2011 18:34:43 +0200 Subject: [PATCH] Improved code a bit :) --- .../main/java/bukkit/tommytony/war/War.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 6c41dad..356c025 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -55,7 +55,7 @@ public class War extends JavaPlugin { private final List zoneMakersImpersonatingPlayers = new ArrayList(); private HashMap disconnected = new HashMap(); private final HashMap wandBearers = new HashMap(); // playername to zonename - + // Default warzone settings private final HashMap defaultLoadout = new HashMap(); private int defaultLifepool = 21; @@ -78,7 +78,7 @@ public class War extends JavaPlugin { private boolean pvpInZonesOnly = false; private boolean disablePvpMessage = false; private boolean buildInZonesOnly = false; - + private WarHub warHub; @@ -559,7 +559,7 @@ public class War extends JavaPlugin { warzone = this.warzone(player.getLocation()); lobby = this.lobby(player.getLocation()); } - + if(warzone == null && lobby != null) { warzone = lobby.getZone(); } else { @@ -569,7 +569,7 @@ public class War extends JavaPlugin { for(Team t : warzone.getTeams()) { if(t.getTeamFlag() != null) t.getFlagVolume().resetBlocks(); t.getSpawnVolume().resetBlocks(); - + // reset inventory for(Player p : t.getPlayers()) { warzone.restorePlayerInventory(p); @@ -1433,8 +1433,7 @@ public class War extends JavaPlugin { return true; } // w/o Permissions, if buildInZonesOnly, no one can build outside the zone except Zonemakers - if(isZoneMaker(player)) return true; - else return false; + return isZoneMaker(player); } else { return true; } @@ -1455,24 +1454,24 @@ public class War extends JavaPlugin { } public boolean isZoneMaker(Player player) { - boolean isPlayerImpersonator = false; for(String disguised : zoneMakersImpersonatingPlayers) { - if(disguised.equals(player.getName())) isPlayerImpersonator = true; + if(disguised.equals(player.getName())) return false; } - if(!isPlayerImpersonator) { - if(player.isOp()) { - return true; - } - for(String zoneMaker : zoneMakerNames) { - if(zoneMaker.equals(player.getName())) return true; - } - if(War.permissionHandler != null - && (War.permissionHandler.has(player, "war.*") - || War.permissionHandler.has(player, "War.*"))) { - return true; - } + + for(String zoneMaker : zoneMakerNames) { + if(zoneMaker.equals(player.getName())) return true; + } + if( War.permissionHandler != null + && ( + War.permissionHandler.has(player, "war.*") + || War.permissionHandler.has(player, "War.*") + ) + ) { + return true; + } + else { + return player.isOp(); } - return false; } public boolean getDefaultAutoAssignOnly() { @@ -1597,7 +1596,7 @@ public class War extends JavaPlugin { public boolean isBuildInZonesOnly() { return buildInZonesOnly; } - + public void setDisablePvpMessage(boolean disablePvpMessage) { this.disablePvpMessage = disablePvpMessage; }