ConfigManager.init(this);
// Setup file logger.
StaticLogFile.setupLogger(new File(getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_BACKEND_FILE_FILENAME)));
final ConfigFile config = ConfigManager.getConfigFile();
useSubscriptions = config.getBoolean(ConfPaths.LOGGING_BACKEND_INGAMECHAT_SUBSCRIPTIONS);
// Initialize MCAccess.
initMCAccess(config);
// Initialize BlockProperties.
initBlockProperties(config);
// Initialize data manager.
disableListeners.add(0, dataMan);
dataMan.onEnable();
// Allow entries to TickTask (just in case).
TickTask.setLocked(false);
// List the events listeners and register.
manageListeners = config.getBoolean(ConfPaths.COMPATIBILITY_MANAGELISTENERS);
if (manageListeners) {
listenerManager.setRegisterDirectly(true);
listenerManager.registerAllWithBukkit();
}
else{
// Just for safety.
listenerManager.setRegisterDirectly(false);
listenerManager.clear();
}
@SetupOrder(priority = - 100)
class ReloadHook implements INotifyReload{
@Override
public void onReload() {
// Only for reloading, not INeedConfig.
processReload();
}
}
// Add the "low level" system components first.
for (final Object obj : new Object[]{
nameSetPerms,
getCoreListener(),
// Put ReloadListener first, because Checks could also listen to it.
new ReloadHook(),
NCPExemptionManager.getListener(),
new ConsistencyChecker() {
@Override
public void checkConsistency(final Player[] onlinePlayers) {
NCPExemptionManager.checkConsistency(onlinePlayers);
}
},
dataMan,
}){
addComponent(obj);
// Register sub-components (allow later added to use registries, if any).
processQueuedSubComponentHolders();
}
// Register "higher level" components (check listeners).
for (final Object obj : new Object[]{
new BlockInteractListener(),
new BlockBreakListener(),
new BlockPlaceListener(),
new ChatListener(),
new CombinedListener(),
// Do mind registration order: Combined must come before Fight.
new FightListener(),
new InventoryListener(),
new MovingListener(),
}){
addComponent(obj);
// Register sub-components (allow later added to use registries, if any).
processQueuedSubComponentHolders();
}
// Register optional default components.
final DefaultComponentFactory dcf = new DefaultComponentFactory();
for (final Object obj : dcf.getAvailableComponentsOnEnable(this)){
addComponent(obj);
// Register sub-components to enable registries for optional components.
processQueuedSubComponentHolders();
}
// Register the commands handler.
final PluginCommand command = getCommand("nocheatplus");
final NoCheatPlusCommand commandHandler = new NoCheatPlusCommand(this, notifyReload);
command.setExecutor(commandHandler);
// (CommandHandler is TabExecutor.)
// Set up the tick task.
TickTask.start(this);
this.dataManTaskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
dataMan.checkExpiration();
}
}, 1207, 1207);
// Set up consistency checking.
scheduleConsistencyCheckers();
// if (config.getBoolean(ConfPaths.MISCELLANEOUS_CHECKFORUPDATES)){
// // Is a new update available?
// final int timeout = config.getInt(ConfPaths.MISCELLANEOUS_UPDATETIMEOUT, 4) * 1000;
// getServer().getScheduler().scheduleAsyncDelayedTask(this, new Runnable() {
// @Override
// public void run() {
// updateAvailable = Updates.checkForUpdates(getDescription().getVersion(), timeout);
// }
// });
// }
// Is the version the configuration was created with consistent with the current one?
configProblems = Updates.isConfigUpToDate(config);
if (configProblems != null && config.getBoolean(ConfPaths.CONFIGVERSION_NOTIFY)){
// Could use custom prefix from logging, however ncp should be mentioned then.
LogUtil.logWarning("[NoCheatPlus] " + configProblems);
}
// Care for already online players.