]> jfr.im git - irc/rizon/moo.git/commitdiff
Fix time checker
authorAdam <redacted>
Fri, 26 Feb 2016 20:17:04 +0000 (15:17 -0500)
committerAdam <redacted>
Fri, 26 Feb 2016 20:17:04 +0000 (15:17 -0500)
commands/src/main/java/net/rizon/moo/plugin/commands/commands.java
commands/src/main/java/net/rizon/moo/plugin/commands/time/CheckTimesTimer.java [new file with mode: 0644]
commands/src/main/java/net/rizon/moo/plugin/commands/time/CommandTime.java
moo/src/main/java/net/rizon/moo/logging/Logger.java

index 005205c19a7c83a4c1d3586861b806db12ace383..7d0277eab00cd1088f2365cccf1850d6b74292c6 100644 (file)
@@ -4,10 +4,13 @@ import com.google.inject.Inject;
 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;
@@ -22,6 +25,7 @@ import net.rizon.moo.plugin.commands.sid.CommandSidHub;
 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;
@@ -66,6 +70,11 @@ public class commands extends Plugin
 
        @Inject
        private CommandWhy why;
+
+       @Inject
+       private CheckTimesTimer checkTimesTimer;
+
+       private ScheduledFuture checkTimesTimerFuture;
        
        public commands()
        {
@@ -75,11 +84,13 @@ public class commands extends Plugin
        @Override
        public void start() throws Exception
        {
+               checkTimesTimerFuture = Moo.scheduleWithFixedDelay(checkTimesTimer, 15, TimeUnit.MINUTES);
        }
 
        @Override
        public void stop()
        {
+               checkTimesTimerFuture.cancel(false);
        }
 
        @Override
@@ -93,6 +104,8 @@ public class commands extends Plugin
        {
                bind(commands.class).toInstance(this);
 
+               bind(CheckTimesTimer.class);
+
                Multibinder<Command> commandBinder = Multibinder.newSetBinder(binder(), Command.class);
                Multibinder<Message> messageBinder = Multibinder.newSetBinder(binder(), Message.class);
 
diff --git a/commands/src/main/java/net/rizon/moo/plugin/commands/time/CheckTimesTimer.java b/commands/src/main/java/net/rizon/moo/plugin/commands/time/CheckTimesTimer.java
new file mode 100644 (file)
index 0000000..4b4c6e7
--- /dev/null
@@ -0,0 +1,30 @@
+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
index 08eef7fc1d6fc7909045242a308c37ae8f14e029..31af4521b2c7addcf8cdc4421e69ba364c8fec26 100644 (file)
@@ -1,45 +1,14 @@
 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
@@ -48,8 +17,6 @@ public class CommandTime extends Command
        @Inject
        private Protocol protocol;
 
-       private ScheduledFuture check_times_timer;
-
        @Inject
        public CommandTime(Config conf)
        {
@@ -57,13 +24,6 @@ public class CommandTime extends Command
 
                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
index 6922d4f8c7b96cb189efa98ad5435afb8dd148ac..0d94fecc934d37ab478520ccde41ac007c5303e6 100644 (file)
@@ -52,7 +52,7 @@ public class Logger extends UnsynchronizedAppenderBase<ILoggingEvent>
                        }
                        if (stes != null)
                        {
-                               if (throwable != null)
+                               if (throwable != null && throwable.getMessage() != null)
                                {
                                        protocol.privmsg(ch, throwable.getMessage());
                                }