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

73 lines
1.4 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());
2015-01-25 05:49:23 +01:00
add(new CommandAdmin());
add(new CommandAfk());
2015-01-25 05:49:23 +01:00
add(new CommandAutomessager());
add(new CommandBroadcast());
add(new CommandCubo());
add(new CommandList());
add(new CommandMe());
add(new CommandPing());
add(new CommandSetblock());
add(new CommandStaff());
add(new CommandSystem());
add(new CommandAnimal());
}
private void add(AbstractCommandExecutor ace) {
commandExecutors.put(ace.getCommandName(), ace);
}
public AbstractCommandExecutor get(String cmdName) {
return commandExecutors.get(cmdName);
}
}