mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-10 21:11:07 +01:00
Add some javadocs
people may forget what these things do later
This commit is contained in:
parent
4d6558afce
commit
7f417ef09b
@ -24,6 +24,11 @@ public class ProviderFactory {
|
|||||||
this.essentials = essentials;
|
this.essentials = essentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the provider which has been selected for the given type.
|
||||||
|
* @param providerClass The provider type.
|
||||||
|
* @return the provider or null if no provider could be selected for that type.
|
||||||
|
*/
|
||||||
public <P extends Provider> P get(final Class<P> providerClass) {
|
public <P extends Provider> P get(final Class<P> providerClass) {
|
||||||
final Provider provider = providers.get(providerClass);
|
final Provider provider = providers.get(providerClass);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
@ -93,6 +98,11 @@ public class ProviderFactory {
|
|||||||
}
|
}
|
||||||
final Object[] args = new Object[constructor.getParameterTypes().length];
|
final Object[] args = new Object[constructor.getParameterTypes().length];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Providers can have constructors with any of the following types, and this code will automatically supply them;
|
||||||
|
- Plugin - The Essentials instance will be passed
|
||||||
|
- boolean - True will be passed if this server is running Paper, otherwise false.
|
||||||
|
*/
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
final Class<?> paramType = constructor.getParameterTypes()[i];
|
final Class<?> paramType = constructor.getParameterTypes()[i];
|
||||||
if (paramType.isAssignableFrom(Plugin.class)) {
|
if (paramType.isAssignableFrom(Plugin.class)) {
|
||||||
|
@ -8,7 +8,14 @@ import java.lang.annotation.Target;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
public @interface ProviderData {
|
public @interface ProviderData {
|
||||||
|
/**
|
||||||
|
* A brief description of when this specific provider is used (MC Version, Server Software) and its name.
|
||||||
|
*/
|
||||||
String description();
|
String description();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If there is multiple providers for a given type that pass their {@link ProviderTest}, the one with the highest weight will be used.
|
||||||
|
* @return the weight of the provider.
|
||||||
|
*/
|
||||||
int weight() default 0;
|
int weight() default 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user