PandacraftUtils/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandsManager.java

70 lines
1.3 KiB
Java
Raw Normal View History

package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
import java.util.HashMap;
/**
* Initialise et stoque toutes les instances des classes exécutant les commandes Minecraft, géré par le plugin
*/
public class CommandsManager {
private static CommandsManager instance;
/**
* Retourne l'unique instance de la classe. Si elle n'existe pas, on tente de créer
* @return L'unique instance de la classe
*/
public synchronized static CommandsManager getInstance() {
if (instance == null)
loadNewInstance();
return instance;
}
public synchronized static void loadNewInstance() {
instance = new CommandsManager();
}
private HashMap<String, AbstractCommandExecutor> commandExecutors = new HashMap<String, AbstractCommandExecutor>();
private CommandsManager() {
/*
* Initialisation des commandes
*/
add(new Command_Selection());
add(new CommandAfk());
add(new CommandBroadcast());
add(new CommandCubo());
add(new CommandList());
add(new CommandMe());
add(new CommandPing());
add(new CommandSetblock());
add(new CommandStaff());
add(new CommandSystem());
}
private void add(AbstractCommandExecutor ace) {
commandExecutors.put(ace.getCommandName(), ace);
}
public AbstractCommandExecutor get(String cmdName) {
return commandExecutors.get(cmdName);
}
}