Skip to content

Commit

Permalink
Unregister placeholders on disable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wertik committed Nov 3, 2020
1 parent 6cd1228 commit 7713bdb
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,38 @@ public void onPluginEnable() {
addMainCommand(new MessageCommand(this));
}

private void setupPlaceholders() {
if (!getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
return;
}
private void unregisterPlaceholders() {

if (placeholders == null)
this.placeholders = new MessagePlaceholders(this);
if (this.placeholders == null)
return;

// Attempt to unregister expansion
if (VersionUtil.compareVersions("2.10.9", PlaceholderAPIPlugin.getInstance().getDescription().getVersion()) > -1 &&
this.placeholders.isRegistered()) {

this.placeholders.unregister();
consoleOutput.debug("Unregistered expansion");
this.placeholders = null;
consoleOutput.debug("Unregistered placeholder expansion.");
}
}

private void setupPlaceholders() {
if (!getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
return;
}

this.unregisterPlaceholders();

this.placeholders = new MessagePlaceholders(this);
this.placeholders.register();
consoleOutput.info("Found PlaceholderAPI! Registered expansion.");
}

@Override
public void onPluginDisable() {
HandlerList.unregisterAll(this);
this.unregisterPlaceholders();

this.userManager.save();
}

Expand Down

0 comments on commit 7713bdb

Please sign in to comment.