From 97f279cd6de4253915975b47ee9279aa6634d1e4 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Fri, 8 Apr 2016 11:35:35 -0700 Subject: [PATCH] Add /DeleteClaimsInWorld --- plugin.yml | 7 +++++ .../GriefPrevention/DataStore.java | 16 ++++++++++++ .../GriefPrevention/GriefPrevention.java | 26 +++++++++++++++++++ .../GriefPrevention/Messages.java | 4 ++- 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index 420ba50..1fefa43 100644 --- a/plugin.yml +++ b/plugin.yml @@ -67,6 +67,10 @@ commands: description: Deletes all of another player's claims. usage: /DeleteAllClaims permission: griefprevention.deleteclaims + deleteclaimsinworld: + description: Deletes all the claims in a world. Only usable at the server console. + usage: /DeleteClaimsInWorld + permission: griefprevention.deleteclaimsinworld adminclaims: description: Switches the shovel tool to administrative claims mode. usage: /AdminClaims @@ -262,6 +266,9 @@ permissions: griefprevention.deleteclaims: description: Grants permission to delete other players' claims. default: op + griefprevention.deleteclaimsinworld: + description: Not used. DeleteClaimsInWorld must be executed at the server console. + default: false griefprevention.adjustclaimblocks: description: Grants permission to add or remove bonus blocks from a player's account. default: op diff --git a/src/me/ryanhamshire/GriefPrevention/DataStore.java b/src/me/ryanhamshire/GriefPrevention/DataStore.java index a3dc922..4e89314 100644 --- a/src/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/me/ryanhamshire/GriefPrevention/DataStore.java @@ -1605,6 +1605,8 @@ public abstract class DataStore this.addDefault(defaults, Messages.BookUsefulCommands, "Useful Commands:", null); this.addDefault(defaults, Messages.NoProfanity, "Please moderate your language.", null); this.addDefault(defaults, Messages.IsIgnoringYou, "That player is ignoring you.", null); + this.addDefault(defaults, Messages.ConsoleOnlyCommand, "That command may only be executed from the server console.", null); + this.addDefault(defaults, Messages.WorldNotFound, "World not found.", null); //load the config file FileConfiguration config = YamlConfiguration.loadConfiguration(new File(messagesFilePath)); @@ -1764,4 +1766,18 @@ public abstract class DataStore return claims; } + + //deletes all the land claims in a specified world + void deleteClaimsInWorld(World world) + { + for(int i = 0; i < claims.size(); i++) + { + Claim claim = claims.get(i); + if(claim.getLesserBoundaryCorner().getWorld().equals(world)) + { + this.deleteClaim(claim, false, false); + i--; + } + } + } } diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index d1afef5..ca2adb4 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -1945,6 +1945,32 @@ public class GriefPrevention extends JavaPlugin return true; } + else if(cmd.getName().equalsIgnoreCase("deleteclaimsinworld")) + { + //must be executed at the console + if(player != null) + { + GriefPrevention.sendMessage(player, TextMode.Err, Messages.ConsoleOnlyCommand); + return true; + } + + //requires exactly one parameter, the world name + if(args.length != 1) return false; + + //try to find the specified world + World world = Bukkit.getServer().getWorld(args[0]); + if(world == null) + { + GriefPrevention.sendMessage(player, TextMode.Err, Messages.WorldNotFound); + return true; + } + + //delete all claims in that world + this.dataStore.deleteClaimsInWorld(world); + GriefPrevention.AddLogEntry("Deleted all claims in world: " + world.getName() + ".", CustomLogEntryTypes.AdminActivity); + return true; + } + //claimbook else if(cmd.getName().equalsIgnoreCase("claimbook")) { diff --git a/src/me/ryanhamshire/GriefPrevention/Messages.java b/src/me/ryanhamshire/GriefPrevention/Messages.java index 8da2a3b..4bce697 100644 --- a/src/me/ryanhamshire/GriefPrevention/Messages.java +++ b/src/me/ryanhamshire/GriefPrevention/Messages.java @@ -241,5 +241,7 @@ public enum Messages MinimumRadius, RadiusRequiresGoldenShovel, ClaimTooSmallForActiveBlocks, - TooManyActiveBlocksInClaim + TooManyActiveBlocksInClaim, + ConsoleOnlyCommand, + WorldNotFound }