use of me.lucko.luckperms.common.treeview.PermissionVault in project LuckPerms by lucko.
the class TabCompletions method getPermissionTabComplete.
public static List<String> getPermissionTabComplete(List<String> args, PermissionVault cache) {
if (args.size() <= 1) {
if (args.isEmpty() || args.get(0).equals("")) {
return cache.getRootNode().getChildren().map(Map::keySet).map(s -> (List<String>) new ArrayList<>(s)).orElse(Collections.emptyList());
}
String start = args.get(0).toLowerCase();
List<String> parts = new ArrayList<>(Splitter.on('.').splitToList(start));
TreeNode root = cache.getRootNode();
if (parts.size() <= 1) {
if (!root.getChildren().isPresent()) {
return Collections.emptyList();
}
return root.getChildren().get().keySet().stream().filter(s -> s.startsWith(start)).collect(Collectors.toList());
}
String incomplete = parts.remove(parts.size() - 1);
for (String s : parts) {
if (!root.getChildren().isPresent()) {
return Collections.emptyList();
}
TreeNode n = root.getChildren().get().get(s);
if (n == null) {
return Collections.emptyList();
}
root = n;
}
if (!root.getChildren().isPresent()) {
return Collections.emptyList();
}
return root.getChildren().get().keySet().stream().filter(s -> s.startsWith(incomplete)).map(s -> parts.stream().collect(Collectors.joining(".")) + "." + s).collect(Collectors.toList());
}
return Collections.emptyList();
}
use of me.lucko.luckperms.common.treeview.PermissionVault 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