Plugin Metadata
Adding plugin metadata helps users to identify your plugin more easily by giving them the ability to check the name, version, description, or even the authors of a plugin at runtime. It will also be used when publishing plugins on a plugin portal like Ore.
Momenteel ondersteunt Sponge de volgende soorten plugin metadata:
Plugin-ID, Plugin naam, Versie
Omschrijving
URL (bij. website)
Auteurs
Plugin dependencies
Plugin annotatie
You can define the additional (optional) plugin metadata on your @Plugin
annotation:
import org.spongepowered.api.plugin.Plugin;
@Plugin(id = "myplugin", name = "My Plugin", version = "1.0",
description = "This is a very cool plugin I made for me",
url = "http://example.com",
authors = {"Spongie", "FLARD"},
dependencies = @Dependency(id = "otherplugin", optional = true))
Bestand metadata
Additionally to plugin metadata defined in the plugin annotation we also recommend plugins to include this metadata in an extra file in the JAR, which has several advantages:
Easier integration for build systems (e.g. contributing the version from the build system into plugin metadata)
Easier for plugin portals to obtain the plugin metadata (no parsing of class files necessary)
Notitie
We strongly recommend public plugins to include file metadata. Plugin portals such as Ore may require file metadata. See Using the Annotation Processor for a simple way to generate it. The implementation may print a warning if a plugin is missing file metadata.
Het mcmod.info formaat
For Sponge plugins, we use a file called mcmod.info
, which is included in the root of your plugin JAR. The format
originates from Forge, and has been used by several projects in the Minecraft community, so we have chosen to use the same.
mcmod.info
is basically a simple JSON file which defines the plugin metadata as simple fields. Here is an example
file that could be used by a Sponge plugin:
[{
"modid": "myplugin",
"name": "My Plugin",
"version": "1.0",
"description": "This is a very cool plugin I made for me",
"authorList": [
"Spongie",
"FLARD"
],
"dependencies": [
"otherplugin"
]
}]
De annotatieprocessor gebruiken
Writing an extra file is quite annoying. Fortunately, usually there is nothing extra you need to do. When compiling
your plugin, SpongeAPI is able to generate this file automatically based on the information provided in your
@Plugin
annotation.
Enabling
If you’re using a build system such as Gradle or Maven and have not explicitly disabled annotation processing there is
nothing extra you need to do. By default the annotation processor will automatically run and generate a mcmod.info
file based on the contents of your @Plugin
annotation.
If you’re not using a build system you need to manually enable annotation processing.
Build system integration
Als u van Gradle gebruikmaakt, zal ‘SpongeGradle <start/project/gradle>’ _ zorgen voor een extra integratie voor Gradle en plugin-metagegevens. Bijvoorbeeld, zal het automatisch bevatten van de versie van de project gedefinieerd in het script Gradle bouwen in de metagegevens van uw plugin. Zie :doc: ‘project/gradle’ voor meer informatie.