diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java index 2e081d5..fcd6433 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java @@ -273,13 +273,20 @@ public class PlaceholderAPI { getPlaceholders().forEach((key, value) -> { if (value instanceof PlaceholderExpansion) { PlaceholderExpansion ex = (PlaceholderExpansion) value; - if (!ex.persist()) { - Bukkit.getPluginManager().callEvent(new ExpansionUnregisterEvent(ex)); - unregisterPlaceholderHook(key); - } + if (!ex.persist()) { + unregisterExpansion(ex); + } } }); } + + public static boolean unregisterExpansion(PlaceholderExpansion ex) { + if (unregisterPlaceholderHook(ex.getIdentifier())) { + Bukkit.getPluginManager().callEvent(new ExpansionUnregisterEvent(ex)); + return true; + } + return false; + } public static Pattern getPlaceholderPattern() { return PLACEHOLDER_PATTERN;