diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java index 902aa47..8a74f6c 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java @@ -1588,6 +1588,8 @@ public abstract class DataStore this.addDefault(defaults, Messages.SubclaimUnrestricted, "This subclaim's permissions will now inherit from the parent claim", null); this.addDefault(defaults, Messages.NetherPortalTrapDetectionMessage, "It seems you might be stuck inside a nether portal. We will rescue you in a few seconds if that is the case!", "Sent to player on join, if they left while inside a nether portal."); + this.addDefault(defaults, Messages.NoSubDivisions, "This claim has no subdivisions.", null); + this.addDefault(defaults, Messages.SubDivisionsRemoved, "This claim has all subdivisions removed.", null); //load the config file FileConfiguration config = YamlConfiguration.loadConfiguration(new File(messagesFilePath)); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 31213c8..29f919c 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -1118,6 +1118,12 @@ public class GriefPrevention extends JavaPlugin return this.abandonClaimHandler(player, true); } + //abandonsublevelclaim + if (cmd.getName().equalsIgnoreCase("abandonsublevelclaim") && player != null) + { + return this.abandonSubLevelClaimHandler(player); + } + //forceabandonclaim if (cmd.getName().equalsIgnoreCase("forceabandonclaim") && player != null) { @@ -2542,6 +2548,40 @@ public class GriefPrevention extends JavaPlugin return location.getWorld().getName() + ": x" + location.getBlockX() + ", z" + location.getBlockZ() + " to x" + location2.getBlockX() + ", z" + location2.getBlockZ(); } + private boolean abandonSubLevelClaimHandler(Player player) + { + //which claim is being abandoned? + Claim claim = this.dataStore.getClaimAt(player.getLocation(), true /*ignore height*/, null); + if (claim == null) + { + GriefPrevention.sendMessage(player, TextMode.Instr, Messages.AbandonClaimMissing); + } + + //verify ownership + else if (claim.checkPermission(player, ClaimPermission.Edit, null) != null) + { + GriefPrevention.sendMessage(player, TextMode.Err, Messages.NotYourClaim); + } + else if (claim.children.isEmpty()) + { + GriefPrevention.sendMessage(player, TextMode.Instr, Messages.NoSubDivisions); + return true; + } + else + { + //delete it + for (Claim subClaim : claim.children) + { + GriefPrevention.instance.dataStore.deleteClaim(subClaim, false, true); + } + //revert any current visualization + Visualization.Revert(player); + } + + return true; + + } + private boolean abandonClaimHandler(Player player, boolean deleteTopLevelClaim) { PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId()); diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/Messages.java b/src/main/java/me/ryanhamshire/GriefPrevention/Messages.java index 14b5b62..b0e7a68 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/Messages.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/Messages.java @@ -255,5 +255,7 @@ public enum Messages SubclaimRestricted, SubclaimUnrestricted, NetherPortalTrapDetectionMessage, - NoClaimTrust + NoClaimTrust, + NoSubDivisions, + SubDivisionsRemoved } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index d2466b2..e88eff5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -15,6 +15,10 @@ commands: description: Deletes a claim and all its subdivisions. usage: /AbandonTopLevelClaim permission: griefprevention.claims + abandonsublevelclaim: + description: Deletes all subdivisions in a claim. + usage: /abandonsublevelclaim + permission: griefprevention.claims abandonallclaims: description: Deletes ALL your claims. usage: /AbandonAllClaims