Search in sources :

Example 1 with InheritanceHandler

use of me.lucko.luckperms.common.inheritance.InheritanceHandler 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)");
}
Also used : UpdateTask(me.lucko.luckperms.common.tasks.UpdateTask) LuckPermsApiProvider(me.lucko.luckperms.common.api.LuckPermsApiProvider) VerboseHandler(me.lucko.luckperms.common.verbose.VerboseHandler) StorageType(me.lucko.luckperms.common.storage.StorageType) PermissionVault(me.lucko.luckperms.common.treeview.PermissionVault) EventFactory(me.lucko.luckperms.common.event.EventFactory) AbstractConfiguration(me.lucko.luckperms.common.config.AbstractConfiguration) CachedStateManager(me.lucko.luckperms.common.caching.handlers.CachedStateManager) InheritanceHandler(me.lucko.luckperms.common.inheritance.InheritanceHandler) SimpleLocaleManager(me.lucko.luckperms.common.locale.SimpleLocaleManager) StorageFactory(me.lucko.luckperms.common.storage.StorageFactory) FileWatcher(me.lucko.luckperms.common.storage.dao.file.FileWatcher) UpdateTaskBuffer(me.lucko.luckperms.common.buffers.UpdateTaskBuffer) LogDispatcher(me.lucko.luckperms.common.actionlog.LogDispatcher) File(java.io.File) LuckPermsCalculator(me.lucko.luckperms.common.contexts.LuckPermsCalculator)

Aggregations

File (java.io.File)1 LogDispatcher (me.lucko.luckperms.common.actionlog.LogDispatcher)1 LuckPermsApiProvider (me.lucko.luckperms.common.api.LuckPermsApiProvider)1 UpdateTaskBuffer (me.lucko.luckperms.common.buffers.UpdateTaskBuffer)1 CachedStateManager (me.lucko.luckperms.common.caching.handlers.CachedStateManager)1 AbstractConfiguration (me.lucko.luckperms.common.config.AbstractConfiguration)1 LuckPermsCalculator (me.lucko.luckperms.common.contexts.LuckPermsCalculator)1 EventFactory (me.lucko.luckperms.common.event.EventFactory)1 InheritanceHandler (me.lucko.luckperms.common.inheritance.InheritanceHandler)1 SimpleLocaleManager (me.lucko.luckperms.common.locale.SimpleLocaleManager)1 StorageFactory (me.lucko.luckperms.common.storage.StorageFactory)1 StorageType (me.lucko.luckperms.common.storage.StorageType)1 FileWatcher (me.lucko.luckperms.common.storage.dao.file.FileWatcher)1 UpdateTask (me.lucko.luckperms.common.tasks.UpdateTask)1 PermissionVault (me.lucko.luckperms.common.treeview.PermissionVault)1 VerboseHandler (me.lucko.luckperms.common.verbose.VerboseHandler)1