diff --git a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java index 096f8d13..3d5ea8e9 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java @@ -179,7 +179,14 @@ private void processFeed(ApplicableRegionSet applicable, Player player, public synchronized void forget(Player player) { states.remove(player.getName()); } - + + /** + * Forget all managed players. Use with caution. + */ + public synchronized void forgetAll() { + states.clear(); + } + /** * Get a player's flag state. * diff --git a/src/main/java/com/sk89q/worldguard/bukkit/commands/WorldGuardCommands.java b/src/main/java/com/sk89q/worldguard/bukkit/commands/WorldGuardCommands.java index a6e46f1f..08a69165 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/commands/WorldGuardCommands.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/commands/WorldGuardCommands.java @@ -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() + "\"."); + } + } + } + }