Skip to content
Browse files

Small change to allow other plugins to use methods from the Command c…

…lasses (for example TweakcraftUtils-GroupChat)
  • Loading branch information...
1 parent f47bc8f commit 7ea4c181d80a2880c93a7c2799c4156b4cab8fc5 @GuntherDW committed Mar 9, 2012
Showing with 34 additions and 7 deletions.
  1. +34 −7 src/com/guntherdw/bukkit/tweakcraft/Commands/CommandHandler.java
View
41 src/com/guntherdw/bukkit/tweakcraft/Commands/CommandHandler.java
@@ -46,6 +46,17 @@
private Map<String, Method> newCommandMap = new HashMap<String, Method>();
private Map<String, Method> aliasCommandMap = new HashMap<String, Method>();
private Map<Method, Object> instanceMap = new HashMap<Method, Object>();
+
+ /** Command Classes **/
+
+ public AdminCommands adminCommands = null;
+ public ChatCommands chatCommands = null;
+ public DebugCommands debugCommands = null;
+ public EssentialsCommands essentialsCommands = null;
+ public GeneralCommands generalCommands = null;
+ public TeleportationCommands teleportationCommands = null;
+ public WeatherCommands weatherCommands = null;
+
private Logger logger = Logger.getLogger("Minecraft");
private TweakcraftUtils plugin;
@@ -61,13 +72,21 @@ public CommandHandler(TweakcraftUtils instance) {
commandMap.clear();
newCommandMap.clear();
- addCommandClass(new AdminCommands(instance));
- addCommandClass(new ChatCommands(instance));
- addCommandClass(new DebugCommands(instance));
- addCommandClass(new EssentialsCommands(instance));
- addCommandClass(new GeneralCommands(instance));
- addCommandClass(new TeleportationCommands(instance));
- addCommandClass(new WeatherCommands(instance));
+ adminCommands = new AdminCommands(instance);
+ chatCommands = new ChatCommands(instance);
+ debugCommands = new DebugCommands(instance);
+ essentialsCommands = new EssentialsCommands(instance);
+ generalCommands = new GeneralCommands(instance);
+ teleportationCommands = new TeleportationCommands(instance);
+ weatherCommands = new WeatherCommands(instance);
+
+ addCommandClass(adminCommands);
+ addCommandClass(chatCommands);
+ addCommandClass(debugCommands);
+ addCommandClass(essentialsCommands);
+ addCommandClass(generalCommands);
+ addCommandClass(teleportationCommands);
+ addCommandClass(weatherCommands);
}
public void addCommandClass(Object instance) {
@@ -138,6 +157,14 @@ public Method getCommand(String command) {
}
}
+ public Object getCommandInstance(Method command) {
+ if (instanceMap.containsKey(command)) {
+ return instanceMap.get(command);
+ } else {
+ return null;
+ }
+ }
+
public boolean executeCommand(CommandSender sender, String name, String[] args) {
String mess = "";

0 comments on commit 7ea4c18

Please sign in to comment.
Something went wrong with that request. Please try again.