|
@@ -34,16 +34,27 @@ import uk.org.ownage.dmdirc.commandparser.commands.server.*;
|
34
|
34
|
public class CommandManager {
|
35
|
35
|
|
36
|
36
|
/**
|
37
|
|
- * The commands that have been instansiated
|
|
37
|
+ * The server commands that have been instansiated
|
38
|
38
|
*/
|
39
|
39
|
private static Vector<Command> serverCommands;
|
40
|
|
-
|
|
40
|
+ /**
|
|
41
|
+ * The channel commands that have been instansiated
|
|
42
|
+ */
|
|
43
|
+ private static Vector<Command> channelCommands;
|
|
44
|
+
|
41
|
45
|
/**
|
42
|
46
|
* Loads all channel commands into the specified parser
|
43
|
47
|
* @param parser The parser to load commands into
|
44
|
48
|
*/
|
45
|
49
|
public static void loadChannelCommands(CommandParser parser) {
|
46
|
|
- throw new UnsupportedOperationException("Not implemented yet");
|
|
50
|
+ if (channelCommands == null) {
|
|
51
|
+ channelCommands = new Vector<Command>(0,1);
|
|
52
|
+
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ for (Command com : channelCommands) {
|
|
56
|
+ parser.registerCommand(com);
|
|
57
|
+ }
|
47
|
58
|
}
|
48
|
59
|
|
49
|
60
|
/**
|
|
@@ -53,17 +64,23 @@ public class CommandManager {
|
53
|
64
|
public static void loadServerCommands(CommandParser parser) {
|
54
|
65
|
if (serverCommands == null) {
|
55
|
66
|
serverCommands = new Vector<Command>(0,1);
|
56
|
|
-
|
|
67
|
+
|
57
|
68
|
serverCommands.add(new Test());
|
58
|
69
|
serverCommands.add(new Quit());
|
59
|
70
|
serverCommands.add(new QuitDefault());
|
60
|
71
|
}
|
61
|
|
-
|
|
72
|
+
|
62
|
73
|
for (Command com : serverCommands) {
|
63
|
74
|
parser.registerCommand(com);
|
64
|
75
|
}
|
65
|
|
- }
|
|
76
|
+ }
|
66
|
77
|
|
|
78
|
+ /**
|
|
79
|
+ * Retrieves the server command identified by the specified signature
|
|
80
|
+ * @param signature The signature to look for
|
|
81
|
+ * @return A server command with a matching signature, or null if none
|
|
82
|
+ * were found.
|
|
83
|
+ */
|
67
|
84
|
public static ServerCommand getServerCommad(String signature) {
|
68
|
85
|
if (serverCommands == null) {
|
69
|
86
|
return null;
|
|
@@ -73,7 +90,7 @@ public class CommandManager {
|
73
|
90
|
if (com.getSignature().equals(signature)) {
|
74
|
91
|
return (ServerCommand) com;
|
75
|
92
|
}
|
76
|
|
- }
|
|
93
|
+ }
|
77
|
94
|
|
78
|
95
|
return null;
|
79
|
96
|
}
|