From 910c81bab89d43eec859645d1c4ccbe36a9e1fe1 Mon Sep 17 00:00:00 2001 From: extendedclip Date: Sat, 24 Mar 2018 12:58:15 -0400 Subject: [PATCH] Added unregisterExpansion method --- .../me/clip/placeholderapi/PlaceholderAPI.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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;