Add an access method for cleanup of stored (check) config instances.

This commit is contained in:
asofold 2012-11-02 08:40:05 +01:00
parent 25c5c48576
commit ea82a57272
2 changed files with 26 additions and 16 deletions

View File

@ -8,20 +8,13 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import fr.neatmonster.nocheatplus.NoCheatPlus;
import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakConfig;
import fr.neatmonster.nocheatplus.checks.blockinteract.BlockInteractConfig;
import fr.neatmonster.nocheatplus.checks.blockplace.BlockPlaceConfig;
import fr.neatmonster.nocheatplus.checks.chat.ChatConfig;
import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig;
import fr.neatmonster.nocheatplus.checks.fight.FightConfig;
import fr.neatmonster.nocheatplus.checks.inventory.InventoryConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.command.CommandHandler.NCPReloadEvent;
import fr.neatmonster.nocheatplus.command.INotifyReload;
import fr.neatmonster.nocheatplus.command.NCPCommand;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.players.DataManager;
import fr.neatmonster.nocheatplus.players.Permissions;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
@ -56,14 +49,7 @@ public class ReloadCommand extends NCPCommand {
// Do the actual reload.
ConfigManager.cleanup();
ConfigManager.init(plugin);
BlockBreakConfig.clear();
BlockInteractConfig.clear();
BlockPlaceConfig.clear();
ChatConfig.clear();
CombinedConfig.clear();
FightConfig.clear();
InventoryConfig.clear();
MovingConfig.clear();
DataManager.clearConfigs(); // Here you have to add XConfig.clear() form now on.
// Tell the plugin to adapt to new config.
for (final INotifyReload component : notifyReload){

View File

@ -20,7 +20,15 @@ import org.bukkit.event.player.PlayerQuitEvent;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationHistory;
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
import fr.neatmonster.nocheatplus.checks.blockbreak.BlockBreakConfig;
import fr.neatmonster.nocheatplus.checks.blockinteract.BlockInteractConfig;
import fr.neatmonster.nocheatplus.checks.blockplace.BlockPlaceConfig;
import fr.neatmonster.nocheatplus.checks.chat.ChatConfig;
import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig;
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
import fr.neatmonster.nocheatplus.checks.fight.FightConfig;
import fr.neatmonster.nocheatplus.checks.inventory.InventoryConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.command.INotifyReload;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigFile;
@ -162,4 +170,20 @@ public class DataManager implements Listener, INotifyReload, INeedConfig{
}
ViolationHistory.clear(checkType);
}
/**
* Clear all stored (check) config instances.<br>
* This does not cleanup ConfigManager, i.e. stored yml-versions.
*/
public static void clearConfigs() {
// The dirty bit !
BlockBreakConfig.clear();
BlockInteractConfig.clear();
BlockPlaceConfig.clear();
ChatConfig.clear();
CombinedConfig.clear();
FightConfig.clear();
InventoryConfig.clear();
MovingConfig.clear();
}
}