|
@@ -23,7 +23,6 @@
|
23
|
23
|
package com.dmdirc.addons.scriptplugin;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.ClientModule.GlobalConfig;
|
26
|
|
-import com.dmdirc.DMDircMBassador;
|
27
|
26
|
import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
|
28
|
27
|
import com.dmdirc.commandparser.BaseCommandInfo;
|
29
|
28
|
import com.dmdirc.commandparser.CommandArguments;
|
|
@@ -39,7 +38,6 @@ import com.dmdirc.plugins.PluginDomain;
|
39
|
38
|
import com.dmdirc.ui.input.AdditionalTabTargets;
|
40
|
39
|
|
41
|
40
|
import java.io.File;
|
42
|
|
-import java.io.FileNotFoundException;
|
43
|
41
|
import java.io.FileWriter;
|
44
|
42
|
import java.io.IOException;
|
45
|
43
|
import java.util.Map;
|
|
@@ -68,14 +66,11 @@ public class ScriptCommand extends Command implements IntelligentCommand {
|
68
|
66
|
private final String scriptDirectory;
|
69
|
67
|
/** Script manager to handle scripts. */
|
70
|
68
|
private final ScriptManager scriptManager;
|
71
|
|
- /** The event bus to post errors to. */
|
72
|
|
- private final DMDircMBassador eventBus;
|
73
|
69
|
|
74
|
70
|
/**
|
75
|
71
|
* Creates a new instance of this command.
|
76
|
72
|
*
|
77
|
73
|
* @param scriptManager Used to manage scripts
|
78
|
|
- * @param eventBus The event bus to post errors to
|
79
|
74
|
* @param globalConfig Global config
|
80
|
75
|
* @param commandController The controller to use for command information.
|
81
|
76
|
* @param domain This plugin's settings domain
|
|
@@ -84,7 +79,6 @@ public class ScriptCommand extends Command implements IntelligentCommand {
|
84
|
79
|
*/
|
85
|
80
|
@Inject
|
86
|
81
|
public ScriptCommand(final ScriptManager scriptManager,
|
87
|
|
- final DMDircMBassador eventBus,
|
88
|
82
|
@Directory(ScriptModule.SCRIPTS) final String scriptDirectory,
|
89
|
83
|
@GlobalConfig final AggregateConfigProvider globalConfig,
|
90
|
84
|
final CommandController commandController,
|
|
@@ -96,7 +90,6 @@ public class ScriptCommand extends Command implements IntelligentCommand {
|
96
|
90
|
this.scriptEngineManager = scriptEngineManager;
|
97
|
91
|
this.scriptDirectory = scriptDirectory;
|
98
|
92
|
this.scriptManager = scriptManager;
|
99
|
|
- this.eventBus = eventBus;
|
100
|
93
|
}
|
101
|
94
|
|
102
|
95
|
@Override
|
|
@@ -135,20 +128,19 @@ public class ScriptCommand extends Command implements IntelligentCommand {
|
135
|
128
|
final String baseFile = scriptDirectory + '/'
|
136
|
129
|
+ globalConfig.getOption(domain, "eval.baseFile");
|
137
|
130
|
if (new File(baseFile).exists()) {
|
138
|
|
- wrapper = new ScriptEngineWrapper(scriptEngineManager, eventBus,
|
139
|
|
- baseFile);
|
|
131
|
+ wrapper = new ScriptEngineWrapper(scriptEngineManager, baseFile);
|
140
|
132
|
} else {
|
141
|
|
- wrapper = new ScriptEngineWrapper(scriptEngineManager, eventBus, null);
|
|
133
|
+ wrapper = new ScriptEngineWrapper(scriptEngineManager, null);
|
142
|
134
|
}
|
143
|
135
|
} else {
|
144
|
|
- wrapper = new ScriptEngineWrapper(scriptEngineManager, eventBus, null);
|
|
136
|
+ wrapper = new ScriptEngineWrapper(scriptEngineManager, null);
|
145
|
137
|
}
|
146
|
138
|
wrapper.getScriptEngine().put("cmd_origin", origin);
|
147
|
139
|
wrapper.getScriptEngine().put("cmd_isSilent", args.isSilent());
|
148
|
140
|
wrapper.getScriptEngine().put("cmd_args", sargs);
|
149
|
141
|
sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Result: " + wrapper.
|
150
|
142
|
getScriptEngine().eval(script));
|
151
|
|
- } catch (FileNotFoundException | ScriptException e) {
|
|
143
|
+ } catch (ScriptException e) {
|
152
|
144
|
sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Exception: " + e + " -> " + e.
|
153
|
145
|
getMessage());
|
154
|
146
|
|