|
@@ -27,6 +27,8 @@ import com.dmdirc.commandparser.parsers.CommandParser;
|
27
|
27
|
import com.dmdirc.commandparser.parsers.GlobalCommandParser;
|
28
|
28
|
import com.dmdirc.interfaces.CommandController;
|
29
|
29
|
|
|
30
|
+import com.google.common.eventbus.EventBus;
|
|
31
|
+
|
30
|
32
|
import java.util.Timer;
|
31
|
33
|
import java.util.TimerTask;
|
32
|
34
|
|
|
@@ -49,6 +51,8 @@ public class TimedCommand extends TimerTask {
|
49
|
51
|
private final TimerManager manager;
|
50
|
52
|
/** The command controller to use when executing global commands. */
|
51
|
53
|
private final CommandController commandController;
|
|
54
|
+ /** Event bus to post events on. */
|
|
55
|
+ private final EventBus eventBus;
|
52
|
56
|
|
53
|
57
|
/**
|
54
|
58
|
* Creates a new instance of TimedCommand.
|
|
@@ -60,6 +64,7 @@ public class TimedCommand extends TimerTask {
|
60
|
64
|
* @param delay The number of seconds between each execution
|
61
|
65
|
* @param command The command to be executed
|
62
|
66
|
* @param origin The frame container to use for the execution
|
|
67
|
+ * @param eventBus The Event bus to post events on
|
63
|
68
|
*/
|
64
|
69
|
public TimedCommand(
|
65
|
70
|
final TimerManager manager,
|
|
@@ -68,13 +73,15 @@ public class TimedCommand extends TimerTask {
|
68
|
73
|
final int repetitions,
|
69
|
74
|
final int delay,
|
70
|
75
|
final String command,
|
71
|
|
- final FrameContainer origin) {
|
|
76
|
+ final FrameContainer origin,
|
|
77
|
+ final EventBus eventBus) {
|
72
|
78
|
this.commandController = commandController;
|
73
|
79
|
this.timerKey = timerKey;
|
74
|
80
|
this.repetitions = repetitions;
|
75
|
81
|
this.command = command;
|
76
|
82
|
this.origin = origin;
|
77
|
83
|
this.manager = manager;
|
|
84
|
+ this.eventBus = eventBus;
|
78
|
85
|
|
79
|
86
|
timer = new Timer("Timed Command Timer");
|
80
|
87
|
timer.schedule(this, delay * 1000L, delay * 1000L);
|
|
@@ -101,7 +108,7 @@ public class TimedCommand extends TimerTask {
|
101
|
108
|
public void run() {
|
102
|
109
|
CommandParser parser;
|
103
|
110
|
if (origin == null) {
|
104
|
|
- parser = new GlobalCommandParser(origin.getConfigManager(), commandController);
|
|
111
|
+ parser = new GlobalCommandParser(origin.getConfigManager(), commandController, eventBus);
|
105
|
112
|
} else {
|
106
|
113
|
parser = origin.getCommandParser();
|
107
|
114
|
}
|