-
Notifications
You must be signed in to change notification settings - Fork 1
LibLoader
Due to file size constraints on plugin hosting services like SpigotMC, some plugins with shaded dependencies might eventually become too large to upload. This is especially important for premium resources that require to be hosted on SpigotMC directly and not via a link to a GitHub release.
Also, shading usually requires you to relocate your dependencies - If you forget to do so your plugin might clash with other ones.
You can easily depend on artifacts by adding a dependencies.json file to your .jar file. Those dependencies will be loaded while your application gets installed as a SimplixApplication (See getting started for more information).
Let's illustrate the usage of the dependency manager with a real-world example. We want to make use of the coroutines that Kotlin provides. The .jar file can be quite big and we plan to reuse it with different plugins so it is wiser to use it as a shared library instead of shading it.
org.jetbrains.kotlinx kotlinx-coroutines-core 1.3.9 providedHow would our dependencies.json look like now?
{
"repositories": [
{
"id": "central",
"url": "https://repo1.maven.org/maven2/"
},
{
"id": "jcenter",
"url": "http://jcenter.bintray.com"
}
],
"dependencies": [
{
"groupId": "org.jetbrains.kotlinx",
"artifactId": "kotlinx-coroutines-core",
"version": "1.3.9"
}
]
}
This is everything codewise we need. Now let's see what will happen when our application starts up.
[18:51:54 INFO] [dev.simplix.core.common.libloader.SimpleLibraryLoader]: [Simplix | LibLoader] Loaded encapsulated library kotlinx-coroutines-core-1.3.9.jar for application Example
You can also depend on plugins that will need to be enabled for your plugin to work. Let's assume that one of your plugins requires the Protocolize plugin to work.
{
"repositories": [
{
"id": "exceptionflug",
"url": "https://mvn.exceptionflug.de/repository/exceptionflug-public/"
}
],
"dependencies": [
{
"groupId": "de.exceptionflug",
"artifactId": "protocolize-plugin",
"version": "${protocolize.version}",
"type": "plugin"
}
]
}
Now let's see the log output:
[19:27:28 INFO] [dev.simplix.core.common.inject.SimplixInstaller]: [Simplix | Bootstrap] Example: Load dependency de.exceptionflug:protocolize-plugin:1.6.5-SNAPSHOT from repository...
And now let's see our plugins folder.
SimplixLibraries are libraries that can be loaded as SimplixApplications so they can make use of the dependency injection capabilities of the SimplixCore. To depend on a SimplixLibrary, you can simply add another dependency to the class you have annotated with the @SimplixApplication annotation.
@SimplixApplication(name = "Example", version = "1.0", authors = "SimplixSoftworks", dependencies = "NAME-OF-LIBRARY-HERE")
If your plugin requires its dependencies during the startup, you can also load your dependencies early (instead of waiting for the SimplixCore to install it)
SimplixCore.instance().earlyLoadDependencies(getClass());
- "library" (default) - Library that will only be available for the plugin that depends on it
- "shared-library" - Library that will be available for all other plugins
- "plugin" - A plugin that needs to be installed before your plugin starts
You can also depend on a library that will only load on a given platform. For example:
"dependencies": [
{
"groupId": "dev.simplix.cirrus",
"artifactId": "cirrus-bungeecord",
"version": "1.0-SNAPSHOT",
"platform": "BUNGEECORD",
"type": "shared-library"
},
{
"groupId": "dev.simplix.cirrus",
"artifactId": "cirrus-spigot",
"version": "1.0-SNAPSHOT",
"platform": "SPIGOT",
"type": "shared-library"
}
]
2020 - SimplixSoftworks
- Introduction
- Getting started
- Maven Dependencies
- How to use the Dependency-Injection
- Localization
- Listener API
- SQL
- Libraries
- Utilities
- Contribute