use of fr.neatmonster.nocheatplus.command.NoCheatPlusCommand.NCPReloadEvent in project NoCheatPlus by NoCheatPlus.
the class ReloadCommand method handleReloadCommand.
/**
* Handle the '/nocheatplus reload' command.
*
* @param sender
* the sender
* @return true, if successful
*/
private void handleReloadCommand(final CommandSender sender) {
final LogManager logManager = NCPAPIProvider.getNoCheatPlusAPI().getLogManager();
if (!sender.equals(Bukkit.getConsoleSender())) {
sender.sendMessage(TAG + "Reloading configuration...");
}
logManager.info(Streams.INIT, TAG + "Reloading configuration...");
// Do the actual reload.
ConfigManager.cleanup();
// (Magic/TODO)
final WorldDataManager worldDataManager = (WorldDataManager) NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager();
ConfigManager.init(access, worldDataManager);
if (logManager instanceof INotifyReload) {
// TODO: This is a band-aid.
((INotifyReload) logManager).onReload();
}
// Remove all cached configs from data.
NCPAPIProvider.getNoCheatPlusAPI().getPlayerDataManager().removeCachedConfigs();
// Reset debug flags to default (temp, heavy).
DataManager.restoreDefaultDebugFlags();
// Tell the registered listeners to adapt to new config, first sort them (!).
Collections.sort(notifyReload, Order.cmpSetupOrder);
for (final INotifyReload component : notifyReload) {
component.onReload();
}
// Say to the other plugins that we've reloaded the configuration.
Bukkit.getPluginManager().callEvent(new NCPReloadEvent());
// Log reloading done.
if (!sender.equals(Bukkit.getConsoleSender())) {
sender.sendMessage(TAG + "Configuration reloaded!");
}
logManager.info(Streams.INIT, TAG + "Configuration reloaded.");
// Queued (!).
logManager.info(Streams.DEFAULT_FILE, StringUtil.join(VersionCommand.getVersionInfo(), "\n"));
}
Aggregations