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);