Added /AdjustBonusClaimBlocksAll

Adjusts bonus claim blocks for all online players.
This commit is contained in:
ryanhamshire 2016-06-04 14:03:33 -07:00
parent c52f0b4da2
commit ba8b4d8293
4 changed files with 42 additions and 1 deletions

View File

@ -53,6 +53,11 @@ commands:
usage: /AdjustBonusClaimBlocks <player> <amount>
permission: griefprevention.adjustclaimblocks
aliases: acb
adjustbonusclaimblocksall:
description: Adds or subtracts bonus claim blocks for all online players.
usage: /AdjustBonusClaimBlocksAll <player> <amount>
permission: griefprevention.adjustclaimblocks
aliases: acball
setaccruedclaimblocks:
description: Updates a player's accrued claim block total.
usage: /SetAccruedClaimBlocks <player> <amount>

View File

@ -1426,6 +1426,7 @@ public abstract class DataStore
this.addDefault(defaults, Messages.NoDeletePermission, "You don't have permission to delete claims.", null);
this.addDefault(defaults, Messages.AllAdminDeleted, "Deleted all administrative claims.", null);
this.addDefault(defaults, Messages.AdjustBlocksSuccess, "Adjusted {0}'s bonus claim blocks by {1}. New total bonus blocks: {2}.", "0: player; 1: adjustment; 2: new total");
this.addDefault(defaults, Messages.AdjustBlocksAllSuccess, "Adjusted all online players' bonus claim blocks by {0}.", "0: adjustment amount");
this.addDefault(defaults, Messages.NotTrappedHere, "You can build here. Save yourself.", null);
this.addDefault(defaults, Messages.RescuePending, "If you stay put for 10 seconds, you'll be teleported out. Please wait.", null);
this.addDefault(defaults, Messages.NonSiegeWorld, "Siege is disabled here.", null);

View File

@ -2202,6 +2202,40 @@ public class GriefPrevention extends JavaPlugin
return true;
}
//adjustbonusclaimblocksall <amount>
else if(cmd.getName().equalsIgnoreCase("adjustbonusclaimblocksall"))
{
//requires exactly one parameter, the amount of adjustment
if(args.length != 1) return false;
//parse the adjustment amount
int adjustment;
try
{
adjustment = Integer.parseInt(args[0]);
}
catch(NumberFormatException numberFormatException)
{
return false; //causes usage to be displayed
}
//for each online player
@SuppressWarnings("unchecked")
Collection<Player> players = (Collection<Player>)this.getServer().getOnlinePlayers();
for(Player onlinePlayer : players)
{
UUID playerID = onlinePlayer.getUniqueId();
PlayerData playerData = this.dataStore.getPlayerData(playerID);
playerData.setBonusClaimBlocks(playerData.getBonusClaimBlocks() + adjustment);
this.dataStore.savePlayerData(playerID, playerData);
}
GriefPrevention.sendMessage(player, TextMode.Success, Messages.AdjustBlocksAllSuccess, String.valueOf(adjustment));
if(player != null) GriefPrevention.AddLogEntry(player.getName() + " adjusted all players' bonus claim blocks by " + adjustment + ".", CustomLogEntryTypes.AdminActivity);
return true;
}
//setaccruedclaimblocks <player> <amount>
else if(cmd.getName().equalsIgnoreCase("setaccruedclaimblocks"))
{

View File

@ -243,5 +243,6 @@ public enum Messages
ClaimTooSmallForActiveBlocks,
TooManyActiveBlocksInClaim,
ConsoleOnlyCommand,
WorldNotFound
WorldNotFound,
AdjustBlocksAllSuccess
}