use of io.github.nucleuspowered.nucleus.modules.core.config.CoreConfig in project Nucleus by NucleusPowered.
the class TestModule method configure.
@Override
protected void configure() {
Path test;
Path test2;
try {
test = Files.createTempDirectory("quick");
test2 = Files.createTempFile(test, "quick", "conf");
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
this.bind(Path.class).annotatedWith(DefaultConfig.class).toInstance(test2);
this.bind(Path.class).annotatedWith(ConfigDir.class).toInstance(test);
this.bind(Game.class).toInstance(Mockito.mock(Game.class));
this.bind(Logger.class).toInstance(Mockito.mock(Logger.class));
CoreConfigAdapter mock = Mockito.mock(CoreConfigAdapter.class);
PowerMockito.replace(PowerMockito.method(CoreConfigAdapter.class, "getNode")).with((obj, method, arguments) -> new CoreConfig());
this.bind(CoreConfigAdapter.class).toInstance(mock);
try {
NucleusPlugin plugin = getMockPlugin();
this.bind(NucleusPlugin.class).toInstance(plugin);
this.bind(UserDataManager.class).toInstance(plugin.getUserDataManager());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of io.github.nucleuspowered.nucleus.modules.core.config.CoreConfig in project Nucleus by NucleusPowered.
the class CoreListener method onReload.
@Override
public void onReload() throws Exception {
CoreConfig c = Nucleus.getNucleus().getInternalServiceManager().getServiceUnchecked(CoreConfigAdapter.class).getNodeOrDefault();
this.getKickOnStopMessage = c.isKickOnStop() ? c.getKickOnStopMessage() : null;
}
use of io.github.nucleuspowered.nucleus.modules.core.config.CoreConfig in project Nucleus by NucleusPowered.
the class NucleusPlugin method reload.
@Override
public synchronized boolean reload() {
try {
this.moduleContainer.reloadSystemConfig();
reloadMessages();
this.commandsConfig.load();
this.itemDataService.load();
this.warmupConfig = null;
CoreConfig coreConfig = this.getInternalServiceManager().getService(CoreConfigAdapter.class).get().getNodeOrDefault();
this.isDebugMode = coreConfig.isDebugmode();
this.isTraceUserCreations = coreConfig.traceUserCreations();
this.savesandloads = coreConfig.isPrintSaveLoad();
for (TextFileController tfc : textFileControllers.values()) {
tfc.load();
}
fireReloadables();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
use of io.github.nucleuspowered.nucleus.modules.core.config.CoreConfig 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.modules.core.config.CoreConfig in project Nucleus by NucleusPowered.
the class RandomTeleportCommand method onReload.
@Override
public void onReload() {
this.rc = this.plugin.getConfigAdapter(RTPModule.ID, RTPConfigAdapter.class).map(TypedAbstractConfigAdapter::getNodeOrDefault).orElseGet(RTPConfig::new);
CoreConfig cc = this.plugin.getInternalServiceManager().getService(CoreConfigAdapter.class).map(TypedAbstractConfigAdapter::getNodeOrDefault).orElseGet(CoreConfig::new);
this.height = cc.getSafeTeleportConfig().getHeight();
}
Aggregations