Added command to flush state manager in case of emergency.

This commit is contained in:
Wizjany 2011-09-24 21:33:59 -04:00
parent 63693cc529
commit 9343c300cd
2 changed files with 28 additions and 1 deletions

View File

@ -179,7 +179,14 @@ private void processFeed(ApplicableRegionSet applicable, Player player,
public synchronized void forget(Player player) { public synchronized void forget(Player player) {
states.remove(player.getName()); states.remove(player.getName());
} }
/**
* Forget all managed players. Use with caution.
*/
public synchronized void forgetAll() {
states.clear();
}
/** /**
* Get a player's flag state. * Get a player's flag state.
* *

View File

@ -124,4 +124,24 @@ public void handleError(String err) {
} }
} }
@Command(aliases = {"flushstates", "clearstates"},
usage = "[player]",
desc = "Flush the state manager",
flags = "", min = 0, max = 1)
@CommandPermissions("worldguard.flushstates")
public static void flushStates(CommandContext args, WorldGuardPlugin plugin,
CommandSender sender) throws CommandException {
if (args.argsLength() == 0) {
plugin.getFlagStateManager().forgetAll();
sender.sendMessage("Cleared all states.");
} else {
Player player = plugin.getServer().getPlayer(args.getString(0));
if (player != null) {
plugin.getFlagStateManager().forget(player);
sender.sendMessage("Cleared states for player \"" + player.getName() + "\".");
}
}
}
} }