Package org.spongepowered.plugin.meta
Class PluginMetadata
java.lang.Object
org.spongepowered.plugin.meta.PluginMetadata
- All Implemented Interfaces:
Consumer<PluginMetadata>
Represents additional metadata for a specific version of a plugin.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPluginMetadata(String id) Constructs a newPluginMetadatawith the specified plugin ID. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(PluginMetadata other) Replaces the properties in thisPluginMetadatawith all properties of the specifiedPluginMetadatathat are not empty.voidAdds an author to theListof authors for this plugin.voidaddAuthors(String... authors) Adds the authors to theListof authors for this plugin.voidaddDependencies(PluginDependency... dependencies) Adds the list ofPluginDependencyto thisPluginMetadata.voidaddDependency(PluginDependency dependency) Adds a newPluginDependencyto thisPluginMetadata.authors()Returns a mutableListof authors for this plugin.Collects all dependencies of thisPluginMetadatathat are not optional.Returns aCollectionwith all dependencies of the plugin represented by thisPluginMetadata.Returns aMapwith all dependencies grouped by their plugin ID.dependency(String id) Returns thePluginDependencythat is currently associated with the specified plugin ID.Returns the plugin description.Returns aMapwith additional properties for thisPluginMetadata.<T> @Nullable TgetExtension(String key) Returns the value for a specific extension.Groups the dependencies of thisPluginMetadatabased on theirPluginDependency.LoadOrder.id()Returns the plugin ID that is represented by thisPluginMetadata.name()Returns the plugin name.booleanremoveAuthor(String author) Removes an author from theListof authors for this plugin.booleanRemoves a dependency from thisPluginMetadata.booleanremoveExtension(String key) Removes an extension from thisPluginMetadata.replaceDependency(PluginDependency dependency) Replaces the currentPluginDependencywith the same plugin ID with a new one.voidsetDescription(@Nullable String description) Sets the plugin description.voidsetExtension(String key, Object extension) Adds the specified extension to thisPluginMetadata.voidSets the plugin ID that is represented by thisPluginMetadata.voidSets the plugin name.voidSets a URL where additional information about a plugin may be found.voidsetVersion(@Nullable String version) Sets the plugin version.toString()url()Returns a URL where additional information about a plugin may be found.version()Returns the plugin version.
-
Field Details
-
ID_PATTERN
The pattern plugin IDs must match. Plugin IDs must be lower case, and start with an alphabetic character. It may only contain alphanumeric characters, dashes or underscores. It must be at least 2 characters, and cannot be longer than 64 characters.
-
-
Constructor Details
-
PluginMetadata
Constructs a newPluginMetadatawith the specified plugin ID.- Parameters:
id- The plugin ID- Throws:
IllegalArgumentException- If the plugin ID is empty
-
-
Method Details
-
id
Returns the plugin ID that is represented by thisPluginMetadata.- Returns:
- The plugin ID
-
setId
Sets the plugin ID that is represented by thisPluginMetadata.- Parameters:
id- The plugin ID- Throws:
IllegalArgumentException- If the plugin ID is empty
-
name
Returns the plugin name.- Returns:
- The plugin name or
nullif unknown
-
setName
Sets the plugin name.- Parameters:
name- The plugin name ornullto reset
-
version
Returns the plugin version.- Returns:
- The plugin version or
nullif unknown
-
setVersion
Sets the plugin version.- Parameters:
version- The plugin version ornullto reset
-
description
Returns the plugin description.- Returns:
- The plugin description or
nullif unknown
-
setDescription
Sets the plugin description.- Parameters:
description- The plugin description ornullto reset
-
url
Returns a URL where additional information about a plugin may be found.- Returns:
- The URL or
nullif unknown
-
setUrl
Sets a URL where additional information about a plugin may be found.- Parameters:
url- The URL ornullto reset
-
authors
Returns a mutableListof authors for this plugin.The returned list can be used to remove an author from the metadata.
- Returns:
- The list of authors, can be empty
-
addAuthor
Adds an author to theListof authors for this plugin.- Parameters:
author- The author to add- Throws:
IllegalArgumentException- If the author is empty
-
addAuthors
Adds the authors to theListof authors for this plugin.- Parameters:
authors- The authors to add- Throws:
IllegalArgumentException- If the author is empty or has any invalid authors
-
removeAuthor
Removes an author from theListof authors for this plugin.- Parameters:
author- The author to remove- Returns:
- True if the operation was successful
-
dependencies
Returns aCollectionwith all dependencies of the plugin represented by thisPluginMetadata.It is possible to remove elements from the returned collection, however new elements must be added using
addDependency(PluginDependency).- Returns:
- A collection with all dependencies
-
dependenciesById
Returns aMapwith all dependencies grouped by their plugin ID.- Returns:
- A map with all dependencies and their plugin IDs
-
collectRequiredDependencies
Collects all dependencies of thisPluginMetadatathat are not optional.- Returns:
- An immutable set of all required dependencies
-
groupDependenciesByLoadOrder
Groups the dependencies of thisPluginMetadatabased on theirPluginDependency.LoadOrder.- Returns:
- An immutable map with all dependencies grouped by their load order
-
dependency
Returns thePluginDependencythat is currently associated with the specified plugin ID.- Parameters:
id- The plugin ID of the dependency- Returns:
- The dependency or
nullif there is no such dependency
-
addDependency
Adds a newPluginDependencyto thisPluginMetadata.- Parameters:
dependency- The dependency to add- Throws:
IllegalArgumentException- If this plugin already has a dependency with the specified plugin ID
-
addDependencies
Adds the list ofPluginDependencyto thisPluginMetadata.- Parameters:
dependencies- The dependencies to add- Throws:
IllegalArgumentException- If the plugins are null or invalid
-
replaceDependency
Replaces the currentPluginDependencywith the same plugin ID with a new one. UnlikeaddDependency(PluginDependency)this method doesn't throw an exception if a dependency with the same plugin ID exists already.- Parameters:
dependency- The dependency to add- Returns:
- The dependency that was previously registered for the plugin ID
or
nullif this is a new dependency
-
removeDependency
Removes a dependency from thisPluginMetadata.- Parameters:
id- The plugin ID of the dependency to remove- Returns:
- True if the operation was successful
-
extensions
Returns aMapwith additional properties for thisPluginMetadata.To serialize arbitrary objects, it may be necessary to register a custom serializer for the extension object.
- Returns:
- An unmodifiable map with additional properties
-
getExtension
Returns the value for a specific extension.Note: This method will not verify if this metadata contains a value with the specified type. A
ClassCastExceptionwill be thrown if the value has a different type.- Type Parameters:
T- The type to cast the extension to- Parameters:
key- The key of the extension- Returns:
- The extension or
nullif not set - Throws:
ClassCastException- If the given type does not match the type of the extension
-
setExtension
Adds the specified extension to thisPluginMetadata.- Parameters:
key- The key of the extensionextension- The extension
-
removeExtension
Removes an extension from thisPluginMetadata.- Parameters:
key- The key of the extension- Returns:
- True if the operation was successful
-
accept
Replaces the properties in thisPluginMetadatawith all properties of the specifiedPluginMetadatathat are not empty.- Specified by:
acceptin interfaceConsumer<PluginMetadata>- Parameters:
other- The plugin metadata to apply- Throws:
IllegalArgumentException- If the plugin IDs don't match
-
toString
-