use of io.github.nucleuspowered.nucleus.internal.CommandPermissionHandler in project Nucleus by NucleusPowered.
the class NucleusPlugin method onPostInit.
@Listener(order = Order.FIRST)
public void onPostInit(GamePostInitializationEvent event) {
if (isErrored != null) {
return;
}
logger.info(messageProvider.getMessageWithFormat("startup.postinit", PluginInfo.NAME));
// Load up the general data files now, mods should have registered items by now.
try {
// Reloadable so that we can update the serialisers.
moduleContainer.reloadSystemConfig();
} catch (Exception e) {
isErrored = e;
disable();
e.printStackTrace();
return;
}
try {
Sponge.getEventManager().post(new BaseModuleEvent.AboutToConstructEvent(this));
logger.info(messageProvider.getMessageWithFormat("startup.moduleloading", PluginInfo.NAME));
moduleContainer.loadModules(true);
CoreConfig coreConfig = moduleContainer.getConfigAdapterForModule(CoreModule.ID, CoreConfigAdapter.class).getNodeOrDefault();
if (coreConfig.isErrorOnStartup()) {
throw new IllegalStateException("In main.conf, core.simulate-error-on-startup is set to TRUE. Remove this config entry to allow Nucleus to start. Simulating error and disabling Nucleus.");
}
this.isDebugMode = coreConfig.isDebugmode();
this.isTraceUserCreations = coreConfig.traceUserCreations();
this.savesandloads = coreConfig.isPrintSaveLoad();
} catch (Throwable construction) {
logger.info(messageProvider.getMessageWithFormat("startup.modulenotloaded", PluginInfo.NAME));
construction.printStackTrace();
disable();
isErrored = construction;
return;
}
// Register a reloadable.
CommandPermissionHandler.onReload();
registerReloadable(CommandPermissionHandler::onReload);
getDocGenCache().ifPresent(x -> x.addTokenDocs(nucleusChatService.getNucleusTokenParser().getTokenNames()));
logger.info(messageProvider.getMessageWithFormat("startup.moduleloaded", PluginInfo.NAME));
registerPermissions();
Sponge.getEventManager().post(new BaseModuleEvent.Complete(this));
logger.info(messageProvider.getMessageWithFormat("startup.completeinit", PluginInfo.NAME));
}
use of io.github.nucleuspowered.nucleus.internal.CommandPermissionHandler in project Nucleus by NucleusPowered.
the class StandardModule method createSeenModule.
protected final void createSeenModule(@Nullable Class<? extends AbstractCommand> permissionClass, BiFunction<CommandSource, User, Collection<Text>> function) {
// Register seen information.
CommandPermissionHandler permissionHandler = plugin.getPermissionRegistry().getPermissionsForNucleusCommand(permissionClass);
createSeenModule(permissionHandler == null ? null : permissionHandler.getBase(), function);
}
use of io.github.nucleuspowered.nucleus.internal.CommandPermissionHandler in project Nucleus by NucleusPowered.
the class NicknameService method register.
public void register() {
if (this.registered) {
return;
}
MessageProvider mp = Nucleus.getNucleus().getMessageProvider();
CommandPermissionHandler permissions = Nucleus.getNucleus().getPermissionRegistry().getPermissionsForNucleusCommand(NicknameCommand.class);
String colPerm = permissions.getPermissionWithSuffix("colour.");
String colPerm2 = permissions.getPermissionWithSuffix("color.");
NameUtil.getColours().forEach((key, value) -> replacements.put(new String[] { colPerm + value.getName(), colPerm2 + value.getName() }, Tuple.of(Pattern.compile("[&]+" + key.toString().toLowerCase(), Pattern.CASE_INSENSITIVE).matcher(""), mp.getTextMessageWithFormat("command.nick.colour.nopermswith", value.getName()))));
String stylePerm = permissions.getPermissionWithSuffix("style.");
NameUtil.getStyleKeys().entrySet().stream().filter(x -> x.getKey() != 'k').forEach((k) -> replacements.put(new String[] { stylePerm + k.getValue().toLowerCase() }, Tuple.of(Pattern.compile("[&]+" + k.getKey().toString().toLowerCase(), Pattern.CASE_INSENSITIVE).matcher(""), mp.getTextMessageWithFormat("command.nick.style.nopermswith", k.getValue().toLowerCase()))));
this.replacements.put(new String[] { permissions.getPermissionWithSuffix("magic") }, Tuple.of(Pattern.compile("[&]+k", Pattern.CASE_INSENSITIVE).matcher(""), mp.getTextMessageWithFormat("command.nick.style.nopermswith", "magic")));
this.registered = true;
}
Aggregations