Added /AdjustBonusClaimBlocksAll
Adjusts bonus claim blocks for all online players.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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"))
|
||||
{
|
||||
|
||||
@@ -243,5 +243,6 @@ public enum Messages
|
||||
ClaimTooSmallForActiveBlocks,
|
||||
TooManyActiveBlocksInClaim,
|
||||
ConsoleOnlyCommand,
|
||||
WorldNotFound
|
||||
WorldNotFound,
|
||||
AdjustBlocksAllSuccess
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user