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

Merged
merged 2 commits into from
Jan 18, 2025
Merged

Conversation

benwoo1110
Copy link
Member

@benwoo1110 benwoo1110 commented Sep 15, 2024


📦 Artifacts generated:

@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

@benwoo1110 benwoo1110 marked this pull request as ready for review January 18, 2025 13:10
@benwoo1110 benwoo1110 merged commit 164c89c into MV5 Jan 18, 2025
1 check passed
@benwoo1110 benwoo1110 deleted the ben/mv5/core-support branch January 18, 2025 13:10
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