mirror of
https://hub.spigotmc.org/stash/scm/spigot/plugin-annotations.git
synced 2025-04-13 09:29:56 +00:00
Add support for @Library annotation
This commit is contained in:
parent
71bc0c2026
commit
4d209deecf
4 changed files with 61 additions and 0 deletions
|
@ -12,6 +12,7 @@ See the [wiki](https://www.spigotmc.org/wiki/plugin-yml/) for more information.
|
||||||
@Author("md_5")
|
@Author("md_5")
|
||||||
@Website("www.spigotmc.org")
|
@Website("www.spigotmc.org")
|
||||||
@LogPrefix("Testing")
|
@LogPrefix("Testing")
|
||||||
|
@Library("com.squareup.okhttp3:okhttp:4.9.0")
|
||||||
@Dependency("WorldEdit")
|
@Dependency("WorldEdit")
|
||||||
@Dependency("Towny")
|
@Dependency("Towny")
|
||||||
@LoadBefore("Towny")
|
@LoadBefore("Towny")
|
||||||
|
@ -37,6 +38,8 @@ load: STARTUP
|
||||||
author: md_5
|
author: md_5
|
||||||
website: www.spigotmc.org
|
website: www.spigotmc.org
|
||||||
prefix: Testing
|
prefix: Testing
|
||||||
|
libraries:
|
||||||
|
- com.squareup.okhttp3:okhttp:4.9.0
|
||||||
depend:
|
depend:
|
||||||
- WorldEdit
|
- WorldEdit
|
||||||
- Towny
|
- Towny
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.bukkit.plugin.java.annotation.permission.Permission;
|
||||||
import org.bukkit.plugin.java.annotation.permission.Permissions;
|
import org.bukkit.plugin.java.annotation.permission.Permissions;
|
||||||
import org.bukkit.plugin.java.annotation.plugin.ApiVersion;
|
import org.bukkit.plugin.java.annotation.plugin.ApiVersion;
|
||||||
import org.bukkit.plugin.java.annotation.plugin.Description;
|
import org.bukkit.plugin.java.annotation.plugin.Description;
|
||||||
|
import org.bukkit.plugin.java.annotation.dependency.Library;
|
||||||
import org.bukkit.plugin.java.annotation.plugin.LoadOrder;
|
import org.bukkit.plugin.java.annotation.plugin.LoadOrder;
|
||||||
import org.bukkit.plugin.java.annotation.plugin.LogPrefix;
|
import org.bukkit.plugin.java.annotation.plugin.LogPrefix;
|
||||||
import org.bukkit.plugin.java.annotation.plugin.Plugin;
|
import org.bukkit.plugin.java.annotation.plugin.Plugin;
|
||||||
|
@ -145,6 +146,14 @@ public class PluginAnnotationProcessor extends AbstractProcessor {
|
||||||
// prefix
|
// prefix
|
||||||
processAndPut( yml, "prefix", mainPluginType, null, LogPrefix.class, String.class );
|
processAndPut( yml, "prefix", mainPluginType, null, LogPrefix.class, String.class );
|
||||||
|
|
||||||
|
// libraries
|
||||||
|
Library[] libraries = mainPluginType.getAnnotationsByType( Library.class );
|
||||||
|
List<String> libraryArr = Lists.newArrayList();
|
||||||
|
for ( Library lib : libraries ) {
|
||||||
|
libraryArr.add( lib.value() );
|
||||||
|
}
|
||||||
|
if ( !libraryArr.isEmpty() ) yml.put( "libraries", libraryArr );
|
||||||
|
|
||||||
// dependencies
|
// dependencies
|
||||||
Dependency[] dependencies = mainPluginType.getAnnotationsByType( Dependency.class );
|
Dependency[] dependencies = mainPluginType.getAnnotationsByType( Dependency.class );
|
||||||
List<String> hardDependencies = Lists.newArrayList();
|
List<String> hardDependencies = Lists.newArrayList();
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.bukkit.plugin.java.annotation.dependency;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part of the plugin annotations framework.
|
||||||
|
* <p>
|
||||||
|
* Represents the libraries a plugin depends on in order to be loaded
|
||||||
|
* <br>
|
||||||
|
* This specific annotation should not be used by people who do not know how
|
||||||
|
* repeating annotations work.
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface Libraries {
|
||||||
|
|
||||||
|
Library[] value() default {};
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package org.bukkit.plugin.java.annotation.dependency;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Repeatable;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a plugin library.
|
||||||
|
* <br>
|
||||||
|
* Libraries are dynamically loaded by the server implementation and should take
|
||||||
|
* the form of groupId:artifactId:version.
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Repeatable(Libraries.class)
|
||||||
|
public @interface Library {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A library that is to be loaded and accessible by this plugin.
|
||||||
|
*/
|
||||||
|
String value();
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue