use of io.github.nucleuspowered.nucleus.api.exceptions.UnremovableModuleException in project Nucleus by NucleusPowered.
the class ModuleRegistrationProxyService method removeModule.
@Override
public void removeModule(String module, Object plugin) throws ModulesLoadedException, UnremovableModuleException, NoModuleException {
if (!canDisableModules()) {
throw new ModulesLoadedException();
}
// The plugin must actually be a plugin.
Preconditions.checkNotNull(plugin);
Plugin pluginAnnotation = plugin.getClass().getAnnotation(Plugin.class);
if (pluginAnnotation == null) {
throw new IllegalArgumentException("plugin must be your plugin instance.");
}
try {
container.disableModule(module);
nucleus.getLogger().info(NucleusPlugin.getNucleus().getMessageProvider().getMessageWithFormat("nucleus.module.disabled.modulerequest", pluginAnnotation.name(), pluginAnnotation.id(), module));
} catch (IllegalStateException e) {
throw new ModulesLoadedException();
} catch (UndisableableModuleException e) {
nucleus.getLogger().warn(NucleusPlugin.getNucleus().getMessageProvider().getMessageWithFormat("nucleus.module.disabled.forceload", pluginAnnotation.name(), pluginAnnotation.id(), module));
nucleus.getLogger().warn(NucleusPlugin.getNucleus().getMessageProvider().getMessageWithFormat("nucleus.module.disabled.forceloadtwo", pluginAnnotation.name()));
throw new UnremovableModuleException();
} catch (uk.co.drnaylor.quickstart.exceptions.NoModuleException e) {
throw new NoModuleException();
}
}
Aggregations