Add /DeleteClaimsInWorld

This commit is contained in:
ryanhamshire
2016-04-08 11:35:35 -07:00
parent 3402efe5c7
commit 97f279cd6d
4 changed files with 52 additions and 1 deletions
@@ -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--;
}
}
}
}
@@ -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"))
{
@@ -241,5 +241,7 @@ public enum Messages
MinimumRadius,
RadiusRequiresGoldenShovel,
ClaimTooSmallForActiveBlocks,
TooManyActiveBlocksInClaim
TooManyActiveBlocksInClaim,
ConsoleOnlyCommand,
WorldNotFound
}