use of me.lucko.luckperms.common.config.AbstractConfiguration in project LuckPerms by lucko.
the class AbstractLuckPermsPlugin method enable.
public final void enable() {
// send the startup banner
displayBanner(getConsoleSender());
// load some utilities early
this.verboseHandler = new VerboseHandler();
this.permissionVault = new PermissionVault();
this.logDispatcher = new LogDispatcher(this);
// load configuration
getLogger().info("Loading configuration...");
this.configuration = new AbstractConfiguration(this, provideConfigurationAdapter());
this.configuration.loadAll();
// load locale
this.localeManager = new SimpleLocaleManager();
this.localeManager.tryLoad(this, new File(getBootstrap().getConfigDirectory(), "lang.yml"));
// now the configuration is loaded, we can create a storage factory and load initial dependencies
StorageFactory storageFactory = new StorageFactory(this);
Set<StorageType> storageTypes = storageFactory.getRequiredTypes(StorageType.H2);
this.dependencyManager.loadStorageDependencies(storageTypes);
// register listeners
registerPlatformListeners();
// first, setup the file watcher, if enabled
if (getConfiguration().get(ConfigKeys.WATCH_FILES)) {
this.fileWatcher = new FileWatcher(this);
getBootstrap().getScheduler().asyncRepeating(this.fileWatcher, 30L);
}
// initialise storage
this.storage = storageFactory.getInstance(StorageType.H2);
this.messagingService = provideMessagingFactory().getInstance();
// setup the update task buffer
this.updateTaskBuffer = new UpdateTaskBuffer(this);
// register commands
registerCommands();
// load internal managers
getLogger().info("Loading internal permission managers...");
this.inheritanceHandler = new InheritanceHandler(this);
this.cachedStateManager = new CachedStateManager();
// setup user/group/track manager
setupManagers();
// init calculator factory
this.calculatorFactory = provideCalculatorFactory();
// setup contextmanager & register common calculators
setupContextManager();
getContextManager().registerStaticCalculator(new LuckPermsCalculator(getConfiguration()));
// setup platform hooks
setupPlatformHooks();
// register with the LP API
this.apiProvider = new LuckPermsApiProvider(this);
this.eventFactory = new EventFactory(this, this.apiProvider);
ApiRegistrationUtil.registerProvider(this.apiProvider);
registerApiOnPlatform(this.apiProvider);
// schedule update tasks
int mins = getConfiguration().get(ConfigKeys.SYNC_TIME);
if (mins > 0) {
long ticks = mins * 60 * 20;
getBootstrap().getScheduler().asyncRepeating(() -> this.updateTaskBuffer.request(), ticks);
}
getBootstrap().getScheduler().asyncLater(() -> this.updateTaskBuffer.request(), 40L);
// run an update instantly.
getLogger().info("Performing initial data load...");
try {
new UpdateTask(this, true).run();
} catch (Exception e) {
e.printStackTrace();
}
// init housekeeping tasks
registerHousekeepingTasks();
// perform any platform-specific final setup tasks
performFinalSetup();
getLogger().info("Successfully enabled. (took " + (System.currentTimeMillis() - getBootstrap().getStartupTime()) + "ms)");
}
Aggregations