|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package net.pingex.discordbot;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class which keeps track of all known loaded modules
|
|
|
|
@ -12,15 +13,31 @@ class ModulesRegistry
|
|
|
|
|
*/
|
|
|
|
|
private static ArrayList<AbstractModule> datastore = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Logger
|
|
|
|
|
*/
|
|
|
|
|
private static Logger LOGGER = Logger.getLogger(ModulesRegistry.class.getName());
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Action to register a loaded module
|
|
|
|
|
* @param toRegister Module to register
|
|
|
|
|
*/
|
|
|
|
|
public static void register(AbstractModule toRegister)
|
|
|
|
|
{
|
|
|
|
|
LOGGER.info("Registering module " + toRegister.getClass().getName());
|
|
|
|
|
datastore.add(toRegister);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove the target module from the list (if it crashed for example)
|
|
|
|
|
* @param target Module to remove
|
|
|
|
|
*/
|
|
|
|
|
public static void unregister(AbstractModule target)
|
|
|
|
|
{
|
|
|
|
|
LOGGER.info("Unregistering module " + target.getClass().getName());
|
|
|
|
|
datastore.remove(target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns of the whole registry
|
|
|
|
|
* @return A clone of the whole registry, to avoid damaging the original registry
|
|
|
|
|