Add some javadocs

people may forget what these things do later
This commit is contained in:
Josh Roy 2023-12-21 11:33:13 -05:00
parent 4d6558afce
commit 7f417ef09b
No known key found for this signature in database
GPG Key ID: 86A69D08540BC29A
2 changed files with 17 additions and 0 deletions

View File

@ -24,6 +24,11 @@ public class ProviderFactory {
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) {
final Provider provider = providers.get(providerClass);
if (provider == null) {
@ -93,6 +98,11 @@ public class ProviderFactory {
}
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++) {
final Class<?> paramType = constructor.getParameterTypes()[i];
if (paramType.isAssignableFrom(Plugin.class)) {

View File

@ -8,7 +8,14 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ProviderData {
/**
* A brief description of when this specific provider is used (MC Version, Server Software) and its name.
*/
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;
}