Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for MV5 core and hk2 injection #98

Draft
wants to merge 1 commit into
base: MV5
Choose a base branch
from

Conversation

benwoo1110
Copy link
Member

No description provided.

@benwoo1110 benwoo1110 changed the base branch from main to MV5 September 15, 2024 01:32
Comment on lines +128 to +138

tasks.register('runHabitatGenerator', JavaExec) {
classpath = configurations["compileClasspath"]
main = 'org.mvplugins.multiverse.external.jvnet.hk2.generator.HabitatGenerator'

args = [
'--file', "build/libs/multiverse-signportals-$version" + ".jar",
'--locator', 'Multiverse-SignPortals',
]
}
tasks.named("build") { finalizedBy("runHabitatGenerator") }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main part that make it work

Comment on lines +72 to 103
private void initializeDependencyInjection() {
serviceLocator = core.getServiceLocatorFactory()
.registerPlugin(new MultiverseSignPortalsPluginBinder(this), core.getServiceLocator())
.flatMap(PluginServiceLocator::enable)
.getOrElseThrow(exception -> {
Logging.severe("Failed to initialize dependency injection!");
getServer().getPluginManager().disablePlugin(this);
return new RuntimeException(exception);
});
}

private void shutdownDependencyInjection() {
Option.of(serviceLocator)
.peek(PluginServiceLocator::disable)
.peek(ignore -> serviceLocator = null);
}

/**
* Function to Register all the Events needed.
*/
private void registerEvents() {
var pluginManager = getServer().getPluginManager();

Try.run(() -> serviceLocator.getAllServices(SignPortalsListener.class).forEach(
listener -> {
Logging.info(listener.toString());
pluginManager.registerEvents(listener, this);
}))
.onFailure(e -> {
throw new RuntimeException("Failed to register listeners. Terminating...", e);
});
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here is the same way of initializing service locator as core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant