|
@@ -22,6 +22,7 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.commandparser.parsers;
|
24
|
24
|
|
|
25
|
+import com.dmdirc.Channel;
|
25
|
26
|
import com.dmdirc.DMDircMBassador;
|
26
|
27
|
import com.dmdirc.FrameContainer;
|
27
|
28
|
import com.dmdirc.commandparser.CommandArguments;
|
|
@@ -36,7 +37,7 @@ import com.dmdirc.commandparser.commands.context.CommandContext;
|
36
|
37
|
import com.dmdirc.events.UnknownCommandEvent;
|
37
|
38
|
import com.dmdirc.interfaces.CommandController;
|
38
|
39
|
import com.dmdirc.interfaces.Connection;
|
39
|
|
-import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
|
40
|
+import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
|
40
|
41
|
import com.dmdirc.util.EventUtils;
|
41
|
42
|
import com.dmdirc.util.collections.RollingList;
|
42
|
43
|
|
|
@@ -74,7 +75,8 @@ public abstract class CommandParser implements Serializable {
|
74
|
75
|
* @param commandManager Command manager to load plugins from
|
75
|
76
|
* @param eventBus The event bus to post events to.
|
76
|
77
|
*/
|
77
|
|
- protected CommandParser(final AggregateConfigProvider configManager,
|
|
78
|
+ protected CommandParser(
|
|
79
|
+ final ReadOnlyConfigProvider configManager,
|
78
|
80
|
final CommandController commandManager,
|
79
|
81
|
final DMDircMBassador eventBus) {
|
80
|
82
|
this.eventBus = eventBus;
|
|
@@ -195,9 +197,9 @@ public abstract class CommandParser implements Serializable {
|
195
|
197
|
}
|
196
|
198
|
|
197
|
199
|
if (someValid) {
|
198
|
|
- for (String channel : parts) {
|
199
|
|
- if (!server.isValidChannelName(channel)) {
|
200
|
|
- origin.addLine("commandError", "Invalid channel name: " + channel);
|
|
200
|
+ for (String channelName : parts) {
|
|
201
|
+ if (!server.isValidChannelName(channelName)) {
|
|
202
|
+ origin.addLine("commandError", "Invalid channel name: " + channelName);
|
201
|
203
|
continue;
|
202
|
204
|
}
|
203
|
205
|
|
|
@@ -206,16 +208,16 @@ public abstract class CommandParser implements Serializable {
|
206
|
208
|
+ args.getCommandName()
|
207
|
209
|
+ (cargs.length > 1 ? ' ' + args.getArgumentsAsString(1) : "");
|
208
|
210
|
|
209
|
|
- if (server.hasChannel(channel)) {
|
210
|
|
- server.getChannel(channel).getCommandParser().parseCommand(origin,
|
211
|
|
- newCommandString, false);
|
|
211
|
+ final Optional<Channel> channel = server.getChannel(channelName);
|
|
212
|
+ if (channel.isPresent()) {
|
|
213
|
+ channel.get().getCommandParser().parseCommand(origin, newCommandString, false);
|
212
|
214
|
} else {
|
213
|
215
|
final Map.Entry<CommandInfo, Command> actCommand = commandManager.getCommand(
|
214
|
216
|
CommandType.TYPE_CHANNEL, command);
|
215
|
217
|
|
216
|
218
|
if (actCommand != null && actCommand.getValue() instanceof ExternalCommand) {
|
217
|
219
|
((ExternalCommand) actCommand.getValue()).execute(
|
218
|
|
- origin, server, channel, silent,
|
|
220
|
+ origin, server, channelName, silent,
|
219
|
221
|
new CommandArguments(commandManager, newCommandString));
|
220
|
222
|
}
|
221
|
223
|
}
|