|
@@ -29,6 +29,7 @@ import com.dmdirc.commandparser.commands.chat.*;
|
29
|
29
|
import com.dmdirc.commandparser.commands.global.*;
|
30
|
30
|
//import com.dmdirc.commandparser.commands.query.*;
|
31
|
31
|
import com.dmdirc.commandparser.commands.server.*;
|
|
32
|
+import com.dmdirc.config.ConfigChangeListener;
|
32
|
33
|
import com.dmdirc.config.IdentityManager;
|
33
|
34
|
import com.dmdirc.logger.ErrorLevel;
|
34
|
35
|
import com.dmdirc.logger.Logger;
|
|
@@ -88,6 +89,14 @@ public final class CommandManager {
|
88
|
89
|
*/
|
89
|
90
|
private static List<Command> channelPopupCommands = new ArrayList<Command>();
|
90
|
91
|
|
|
92
|
+ /** The command char we're using. */
|
|
93
|
+ private static char commandChar = IdentityManager.getGlobalConfig()
|
|
94
|
+ .getOption("general", "commandchar").charAt(0);
|
|
95
|
+
|
|
96
|
+ /** The silence char we're using. */
|
|
97
|
+ private static char silenceChar = IdentityManager.getGlobalConfig()
|
|
98
|
+ .getOption("general", "silencechar").charAt(0);
|
|
99
|
+
|
91
|
100
|
/**
|
92
|
101
|
* Prevents creation of a new command manager.
|
93
|
102
|
*/
|
|
@@ -95,6 +104,24 @@ public final class CommandManager {
|
95
|
104
|
//do nothing
|
96
|
105
|
}
|
97
|
106
|
|
|
107
|
+ /**
|
|
108
|
+ * Returns the current command character.
|
|
109
|
+ *
|
|
110
|
+ * @return the current command char
|
|
111
|
+ */
|
|
112
|
+ public static char getCommandChar() {
|
|
113
|
+ return commandChar;
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ /**
|
|
117
|
+ * Returns the current silence character.
|
|
118
|
+ *
|
|
119
|
+ * @return the current silence char
|
|
120
|
+ */
|
|
121
|
+ public static char getSilenceChar() {
|
|
122
|
+ return silenceChar;
|
|
123
|
+ }
|
|
124
|
+
|
98
|
125
|
/**
|
99
|
126
|
* Registers a command with the command manager.
|
100
|
127
|
* @param command The command to be registered
|
|
@@ -179,8 +206,7 @@ public final class CommandManager {
|
179
|
206
|
private static void registerCommandName(final Command command,
|
180
|
207
|
final boolean register) {
|
181
|
208
|
// Do tab completion
|
182
|
|
- final String commandName = IdentityManager.getGlobalConfig()
|
183
|
|
- .getOption("general", "commandchar") + command.getName();
|
|
209
|
+ final String commandName = getCommandChar() + command.getName();
|
184
|
210
|
|
185
|
211
|
for (Server server : ServerManager.getServerManager().getServers()) {
|
186
|
212
|
if (command instanceof ServerCommand || command instanceof GlobalCommand) {
|
|
@@ -303,6 +329,19 @@ public final class CommandManager {
|
303
|
329
|
new SaveConfig();
|
304
|
330
|
new SaveFormatter();
|
305
|
331
|
new Set();
|
|
332
|
+
|
|
333
|
+ // Set up a listener for config changes
|
|
334
|
+ final ConfigChangeListener listener = new ConfigChangeListener() {
|
|
335
|
+ public void configChanged(String domain, String key, String oldValue, String newValue) {
|
|
336
|
+ commandChar = IdentityManager.getGlobalConfig()
|
|
337
|
+ .getOption("general", "commandchar").charAt(0);
|
|
338
|
+ silenceChar = IdentityManager.getGlobalConfig()
|
|
339
|
+ .getOption("general", "silencechar").charAt(0);
|
|
340
|
+ }
|
|
341
|
+ };
|
|
342
|
+
|
|
343
|
+ IdentityManager.getGlobalConfig().addChangeListener("general", "commandchar", listener);
|
|
344
|
+ IdentityManager.getGlobalConfig().addChangeListener("general", "silencechar", listener);
|
306
|
345
|
}
|
307
|
346
|
|
308
|
347
|
/**
|
|
@@ -627,7 +666,7 @@ public final class CommandManager {
|
627
|
666
|
final List<String> res = new ArrayList<String>();
|
628
|
667
|
|
629
|
668
|
for (Command command : source) {
|
630
|
|
- res.add(IdentityManager.getGlobalConfig().getOption("general", "commandchar") + command.getName());
|
|
669
|
+ res.add(getCommandChar() + command.getName());
|
631
|
670
|
}
|
632
|
671
|
|
633
|
672
|
return res;
|