From b99ad5a09a4fa9cf731e6138683ff5628ae867ed Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 9 Aug 2017 10:30:04 -0700 Subject: [PATCH] Add plugin removal from the plugin manager. --- .../org/nwapw/abacus/plugin/PluginManager.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/org/nwapw/abacus/plugin/PluginManager.java b/src/main/java/org/nwapw/abacus/plugin/PluginManager.java index 9ec48b4..46c9517 100644 --- a/src/main/java/org/nwapw/abacus/plugin/PluginManager.java +++ b/src/main/java/org/nwapw/abacus/plugin/PluginManager.java @@ -187,6 +187,24 @@ public class PluginManager { } } + /** + * Removes the plugin with the given class from the manager. + * @param toRemove the plugin to remove. + */ + public void removeClass(Class toRemove){ + if(!loadedPluginClasses.contains(toRemove)) return; + plugins.removeIf(plugin -> plugin.getClass() == toRemove); + loadedPluginClasses.remove(toRemove); + } + + /** + * Removes all plugins from this plugin manager. + */ + public void removeAll(){ + loadedPluginClasses.clear(); + plugins.clear(); + } + /** * Loads all the plugins in the PluginManager. */