import net.rizon.moo.plugin.commands.why.CommandWhy;
import net.rizon.moo.plugin.commands.version.CommandVersions;
import com.google.inject.multibindings.Multibinder;
+import io.netty.util.concurrent.ScheduledFuture;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import net.rizon.moo.Command;
import net.rizon.moo.Message;
+import net.rizon.moo.Moo;
import net.rizon.moo.Plugin;
import net.rizon.moo.plugin.commands.climit.CommandClimit;
import net.rizon.moo.plugin.commands.climit.Message005;
import net.rizon.moo.plugin.commands.slackers.CommandSlackers;
import net.rizon.moo.plugin.commands.slackers.Message219Slackers;
import net.rizon.moo.plugin.commands.slackers.Message249;
+import net.rizon.moo.plugin.commands.time.CheckTimesTimer;
import net.rizon.moo.plugin.commands.time.CommandTime;
import net.rizon.moo.plugin.commands.time.Message391;
import net.rizon.moo.plugin.commands.uptime.CommandUptime;
@Inject
private CommandWhy why;
+
+ @Inject
+ private CheckTimesTimer checkTimesTimer;
+
+ private ScheduledFuture checkTimesTimerFuture;
public commands()
{
@Override
public void start() throws Exception
{
+ checkTimesTimerFuture = Moo.scheduleWithFixedDelay(checkTimesTimer, 15, TimeUnit.MINUTES);
}
@Override
public void stop()
{
+ checkTimesTimerFuture.cancel(false);
}
@Override
{
bind(commands.class).toInstance(this);
+ bind(CheckTimesTimer.class);
+
Multibinder<Command> commandBinder = Multibinder.newSetBinder(binder(), Command.class);
Multibinder<Message> messageBinder = Multibinder.newSetBinder(binder(), Message.class);
--- /dev/null
+package net.rizon.moo.plugin.commands.time;
+
+import com.google.inject.Inject;
+import net.rizon.moo.irc.Protocol;
+import net.rizon.moo.irc.Server;
+import net.rizon.moo.irc.ServerManager;
+
+public class CheckTimesTimer implements Runnable
+{
+ @Inject
+ private ServerManager serverManager;
+
+ @Inject
+ private Protocol protocol;
+
+ @Override
+ public void run()
+ {
+ Message391.known_times.clear();
+ Message391.hourly_check = true;
+
+ for (Server s : serverManager.getServers())
+ {
+ if (s.isServices())
+ continue;
+ protocol.write("TIME", s.getName());
+ Message391.waiting_for.add(s.getName());
+ }
+ }
+}
\ No newline at end of file
package net.rizon.moo.plugin.commands.time;
import com.google.inject.Inject;
-import io.netty.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
import net.rizon.moo.Command;
import net.rizon.moo.CommandSource;
-import net.rizon.moo.Moo;
import net.rizon.moo.conf.Config;
import net.rizon.moo.irc.Protocol;
import net.rizon.moo.irc.Server;
import net.rizon.moo.irc.ServerManager;
-
-class CheckTimesTimer implements Runnable
-{
- private final ServerManager serverManager;
- private final Protocol protocol;
-
- public CheckTimesTimer(ServerManager serverManager, Protocol protocol)
- {
- this.serverManager = serverManager;
- this.protocol = protocol;
- }
-
- @Override
- public void run()
- {
- Message391.known_times.clear();
- Message391.hourly_check = true;
-
- for (Server s : serverManager.getServers())
- {
- if (s.isServices())
- continue;
- protocol.write("TIME", s.getName());
- Message391.waiting_for.add(s.getName());
- }
- }
-}
-
public class CommandTime extends Command
{
@Inject
@Inject
private Protocol protocol;
- private ScheduledFuture check_times_timer;
-
@Inject
public CommandTime(Config conf)
{
this.requiresChannel(conf.oper_channels);
this.requiresChannel(conf.admin_channels);
-
- this.check_times_timer = Moo.scheduleWithFixedDelay(new CheckTimesTimer(serverManager, protocol), 15, TimeUnit.MINUTES);
- }
-
- public void remove()
- {
- this.check_times_timer.cancel(false);
}
@Override
}
if (stes != null)
{
- if (throwable != null)
+ if (throwable != null && throwable.getMessage() != null)
{
protocol.privmsg(ch, throwable.getMessage());
}