diff --git a/src/main/java/space/devport/wertik/custommessages/MessagePlugin.java b/src/main/java/space/devport/wertik/custommessages/MessagePlugin.java index f5ee128..627ef38 100644 --- a/src/main/java/space/devport/wertik/custommessages/MessagePlugin.java +++ b/src/main/java/space/devport/wertik/custommessages/MessagePlugin.java @@ -52,22 +52,29 @@ 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."); } @@ -75,6 +82,8 @@ private void setupPlaceholders() { @Override public void onPluginDisable() { HandlerList.unregisterAll(this); + this.unregisterPlaceholders(); + this.userManager.save(); }