updated local manager to allow for reregistering expansions

This commit is contained in:
Sxtanna 2020-07-25 11:55:24 -04:00
parent 5861f9fe6a
commit 85b9fc36da

View File

@ -186,14 +186,22 @@ public final class LocalExpansionManager implements Listener
} }
} }
final ExpansionRegisterEvent event = new ExpansionRegisterEvent(expansion); final PlaceholderExpansion removed = expansions.get(expansion.getIdentifier());
Bukkit.getPluginManager().callEvent(event); if (removed != null && !unregister(removed))
if (event.isCancelled() || expansions.put(expansion.getIdentifier(), expansion) != null)
{ {
return false; 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) if (expansion instanceof Listener)
{ {
Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin); Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);