From 55b5ecfdbf4c14bac882c511247b78f545e57c53 Mon Sep 17 00:00:00 2001 From: TimWolla Date: Mon, 23 May 2011 18:22:33 +0200 Subject: [PATCH] Closes https://github.com/taoneill/war/issues/44, warzones can be deleted by name now --- .../main/java/bukkit/tommytony/war/War.java | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index 7001d80..4cf9340 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -232,7 +232,7 @@ public class War extends JavaPlugin { } else if(command.equals("resetzone")) { performResetZone(player, arguments); } else if(command.equals("deletezone")) { - performDeleteZone(player); + performDeleteZone(player, arguments); } else if(command.equals("setteam")) { performSetTeam(player, arguments); } else if(command.equals("setteamflag")) { @@ -564,14 +564,29 @@ public class War extends JavaPlugin { } } - public void performDeleteZone(Player player) { - if(!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) { - this.badMsg(player, "Usage: /deletezone. " + + public void performDeleteZone(Player player, String[] arguments) { + if(arguments.length == 0 && !this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) { + this.badMsg(player, "Usage: /deletezone [warzone-name]. " + "Deletes the warzone. " + - "Must be in the warzone (try /zones and /zone). "); + "Must be in the warzone or name must be provided (try /zones and /zone). "); } else { - Warzone warzone = this.warzone(player.getLocation()); - ZoneLobby lobby = this.lobby(player.getLocation()); + ZoneLobby lobby = null; + Warzone warzone = null; + if(arguments.length == 1) { // get zone by name + for(Warzone tmp : this.getWarzones()) { + if(tmp.getName().toLowerCase().startsWith(arguments[0].toLowerCase())) { + warzone = tmp; + break; + } + } + if (warzone == null) { + this.badMsg(player, "No such warzone."); + return; + } + } else { // get zone by position + warzone = this.warzone(player.getLocation()); + lobby = this.lobby(player.getLocation()); + } if(warzone == null && lobby != null) { warzone = lobby.getZone(); } else {