From 85b9fc36da04b2b3d492e47e472aeac18d091a11 Mon Sep 17 00:00:00 2001 From: Sxtanna Date: Sat, 25 Jul 2020 11:55:24 -0400 Subject: [PATCH] updated local manager to allow for reregistering expansions --- .../expansion/manager/LocalExpansionManager.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 c6ca1af..50c39f5 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -186,14 +186,22 @@ public final class LocalExpansionManager implements Listener } } - final ExpansionRegisterEvent event = new ExpansionRegisterEvent(expansion); - Bukkit.getPluginManager().callEvent(event); - - if (event.isCancelled() || expansions.put(expansion.getIdentifier(), expansion) != null) + final PlaceholderExpansion removed = expansions.get(expansion.getIdentifier()); + if (removed != null && !unregister(removed)) { return false; } + final ExpansionRegisterEvent event = new ExpansionRegisterEvent(expansion); + Bukkit.getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return false; + } + + expansions.put(expansion.getIdentifier(), expansion); + if (expansion instanceof Listener) { Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);