Skip to content

Commit

Permalink
Adjusted Javadocs
Browse files Browse the repository at this point in the history
- Added new Javadocs and modified existing ones
- Renamed 'AnnoyingPlugin#reload()' to 'AnnoyingPlugin#reloadPlugin()'
  • Loading branch information
srnyx committed Dec 16, 2022
1 parent e222aa7 commit c3505f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description = "AnnoyingAPI"
version = "1.1.10"
version = "1.1.11"
group = "xyz.srnyx"

repositories {
Expand Down
23 changes: 16 additions & 7 deletions src/main/java/xyz/srnyx/annoyingapi/AnnoyingPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class AnnoyingPlugin extends JavaPlugin {
*/
@NotNull private static final Set<String> MISSING_DEPENDENCIES = new HashSet<>();

/**
* Instance of {@link AnnoyingCommandRegister}, used to other plugins' register commands
*/
@NotNull public final AnnoyingCommandRegister commandRegister = new AnnoyingCommandRegister();

/**
Expand Down Expand Up @@ -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.
* <p>Do not try to override this method! Override {@link #load()} instead
*
* @see #load()
*/
@Override
public final void onLoad() {
messages = new AnnoyingResource(this, options.messagesFileName);
Expand All @@ -76,7 +86,7 @@ public final void onLoad() {

/**
* Called when the plugin is enabled.
* <p>Do not override this method! Override {@link #enable()} instead
* <p>Do not try to override this method! Override {@link #enable()} instead
*
* @see #enable()
*/
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -136,7 +146,7 @@ private void enablePlugin() {

/**
* Called when the plugin is disabled
* <p>Do not override this method! Override {@link #disable()} instead
* <p>Do not try to override this method! Override {@link #disable()} instead
*
* @see #disable()
*/
Expand Down Expand Up @@ -181,10 +191,9 @@ public void log(@Nullable Level level, @NotNull String message) {
}

/**
* Unloads the plugin
* <p><i>This is not meant to be overriden, only override if you know what you're doing!</i>
* 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);
Expand All @@ -196,7 +205,7 @@ public final void unload() {
* Reloads the plugin (calls {@link PluginManager#disablePlugin(Plugin)} and then {@link PluginManager#enablePlugin(Plugin)})
* <p><i>This is not meant to be overriden, only override if you know what you're doing!</i>
*/
public void reload() {
public void reloadPlugin() {
final PluginManager manager = Bukkit.getPluginManager();
manager.disablePlugin(this);
manager.enablePlugin(this);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/xyz/srnyx/testplugin/TestCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c3505f7

Please sign in to comment.