diff --git a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java index 3fb24f9..e72155a 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java @@ -110,7 +110,12 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * command is used * * @return if this expansion should persist through placeholder reloads + * + * @deprecated PlaceholderExpansions registered through their {@link #register()} and not through + * {@link me.clip.placeholderapi.expansion.manager.LocalExpansionManager#register(Class)} + * will be considered internal now and not be unregistered during Plugin reloads. */ + @Deprecated public boolean persist() { return false; } diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java index 1584a5f..214179e 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -46,6 +46,7 @@ import me.clip.placeholderapi.expansion.Cacheable; import me.clip.placeholderapi.expansion.Cleanable; import me.clip.placeholderapi.expansion.Configurable; import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import me.clip.placeholderapi.expansion.PlaceholderExpansion.Type; import me.clip.placeholderapi.expansion.Taskable; import me.clip.placeholderapi.expansion.VersionSpecific; import me.clip.placeholderapi.expansion.cloud.CloudExpansion; @@ -264,6 +265,9 @@ public final class LocalExpansionManager implements Listener { if (expansion instanceof VersionSpecific) { VersionSpecific nms = (VersionSpecific) expansion; + Msg.warn("Nag Author(s) %s of expansion %s about their usage of the deprecated " + + "VersionSpecific interface!", expansion.getAuthor(), expansion.getIdentifier()); + Msg.warn("They should switch to a new method of determining the Server version."); if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion())) { Msg.warn("Your server version is incompatible with expansion %s %s", expansion.getIdentifier(), expansion.getVersion()); @@ -323,6 +327,19 @@ public final class LocalExpansionManager implements Listener { if (expansions.remove(expansion.getIdentifier().toLowerCase(Locale.ROOT)) == null) { return false; } + + // Don't unregister expansions that are marked internal or set to be persistent. + if (expansion.getExpansionType() == Type.INTERNAL || expansion.persist()) { + // Print warning if an external expansion is set to be persistent. + if (expansion.getExpansionType() == Type.EXTERNAL && expansion.persist()) { + Msg.warn("Nag author(s) %s about their expansion %s being marked as \"external\" " + + "but having persist() set to true!", expansion.getAuthor(), expansion.getIdentifier()); + Msg.warn("External Expansions should not be set to be persistent! PlaceholderAPI " + + "will respect this setting and skip the unregister of this Expansion..."); + } + + return true; + } Bukkit.getPluginManager().callEvent(new ExpansionUnregisterEvent(expansion)); @@ -393,7 +410,7 @@ public final class LocalExpansionManager implements Listener { private void unregisterAll() { for (final PlaceholderExpansion expansion : Sets.newHashSet(expansions.values())) { - if (expansion.persist()) { + if (expansion.persist() || expansion.getExpansionType() == Type.INTERNAL) { continue; }