From 7f417ef09bd075123b8c8428a0f8c42c71d35bac Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:33:13 -0500 Subject: [PATCH] Add some javadocs people may forget what these things do later --- .../java/com/earth2me/essentials/ProviderFactory.java | 10 ++++++++++ .../java/net/essentialsx/providers/ProviderData.java | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/Essentials/src/main/java/com/earth2me/essentials/ProviderFactory.java b/Essentials/src/main/java/com/earth2me/essentials/ProviderFactory.java index 21a974c4b..1521ba697 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/ProviderFactory.java +++ b/Essentials/src/main/java/com/earth2me/essentials/ProviderFactory.java @@ -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 get(final Class

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)) { diff --git a/providers/BaseProviders/src/main/java/net/essentialsx/providers/ProviderData.java b/providers/BaseProviders/src/main/java/net/essentialsx/providers/ProviderData.java index fc54309ee..3f0508472 100644 --- a/providers/BaseProviders/src/main/java/net/essentialsx/providers/ProviderData.java +++ b/providers/BaseProviders/src/main/java/net/essentialsx/providers/ProviderData.java @@ -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; }