From c3505f70ac018d918101ba7cc5ad4e25e9420aaa Mon Sep 17 00:00:00 2001 From: srnyx <25808801+srnyx@users.noreply.github.com> Date: Thu, 15 Dec 2022 19:14:50 -0500 Subject: [PATCH] Adjusted Javadocs - Added new Javadocs and modified existing ones - Renamed 'AnnoyingPlugin#reload()' to 'AnnoyingPlugin#reloadPlugin()' --- build.gradle.kts | 2 +- .../xyz/srnyx/annoyingapi/AnnoyingPlugin.java | 23 +++++++++++++------ .../xyz/srnyx/testplugin/TestCommand.java | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ac3ab6e..9ddf293 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ description = "AnnoyingAPI" -version = "1.1.10" +version = "1.1.11" group = "xyz.srnyx" repositories { diff --git a/src/main/java/xyz/srnyx/annoyingapi/AnnoyingPlugin.java b/src/main/java/xyz/srnyx/annoyingapi/AnnoyingPlugin.java index b676306..544a9a8 100644 --- a/src/main/java/xyz/srnyx/annoyingapi/AnnoyingPlugin.java +++ b/src/main/java/xyz/srnyx/annoyingapi/AnnoyingPlugin.java @@ -30,6 +30,9 @@ public class AnnoyingPlugin extends JavaPlugin { */ @NotNull private static final Set MISSING_DEPENDENCIES = new HashSet<>(); + /** + * Instance of {@link AnnoyingCommandRegister}, used to other plugins' register commands + */ @NotNull public final AnnoyingCommandRegister commandRegister = new AnnoyingCommandRegister(); /** @@ -63,6 +66,13 @@ public AnnoyingPlugin() { } } + /** + * Called after a plugin is loaded but before it has been enabled. + * When multiple plugins are loaded, the onLoad() for all plugins is called before any onEnable() is called. + *

Do not try to override this method! Override {@link #load()} instead + * + * @see #load() + */ @Override public final void onLoad() { messages = new AnnoyingResource(this, options.messagesFileName); @@ -76,7 +86,7 @@ public final void onLoad() { /** * Called when the plugin is enabled. - *

Do not override this method! Override {@link #enable()} instead + *

Do not try to override this method! Override {@link #enable()} instead * * @see #enable() */ @@ -112,7 +122,7 @@ private void enablePlugin() { for (final AnnoyingDependency dependency : options.dependencies) { if (dependency.required && dependency.isNotInstalled()) { log(Level.SEVERE, "&cMissing dependency, &4" + dependency.name + "&c is required! Unloading plugin..."); - if (!getName().equals("AnnoyingAPI")) unload(); + if (!getName().equals("AnnoyingAPI")) unloadPlugin(); return; } } @@ -136,7 +146,7 @@ private void enablePlugin() { /** * Called when the plugin is disabled - *

Do not override this method! Override {@link #disable()} instead + *

Do not try to override this method! Override {@link #disable()} instead * * @see #disable() */ @@ -181,10 +191,9 @@ public void log(@Nullable Level level, @NotNull String message) { } /** - * Unloads the plugin - *

This is not meant to be overriden, only override if you know what you're doing! + * Unloads the plugin (not the API) */ - public final void unload() { + public final void unloadPlugin() { // Unregister commands listeners, cancel tasks, and disable the plugin options.commands.forEach(AnnoyingCommand::unregister); options.listeners.forEach(AnnoyingListener::unregister); @@ -196,7 +205,7 @@ public final void unload() { * Reloads the plugin (calls {@link PluginManager#disablePlugin(Plugin)} and then {@link PluginManager#enablePlugin(Plugin)}) *

This is not meant to be overriden, only override if you know what you're doing! */ - public void reload() { + public void reloadPlugin() { final PluginManager manager = Bukkit.getPluginManager(); manager.disablePlugin(this); manager.enablePlugin(this); diff --git a/src/test/java/xyz/srnyx/testplugin/TestCommand.java b/src/test/java/xyz/srnyx/testplugin/TestCommand.java index 39036cb..2bfe908 100644 --- a/src/test/java/xyz/srnyx/testplugin/TestCommand.java +++ b/src/test/java/xyz/srnyx/testplugin/TestCommand.java @@ -60,7 +60,7 @@ public void onCommand(@NotNull AnnoyingSender sender) { if (sender.argEquals(0, "test")) { new AnnoyingMessage(plugin, "test").send(sender); } else if (sender.argEquals(0, "reload")) { - plugin.reload(); + plugin.reloadPlugin(); } cooldown.start();