🚨 Add @Nonnull annotation
[Sone.git] / src / main / java / net / pterodactylus / sone / main / SonePlugin.java
index b79df7c..91f21eb 100644 (file)
@@ -22,7 +22,10 @@ import static java.util.logging.Logger.*;
 import java.util.logging.Logger;
 import java.util.logging.*;
 
+import javax.annotation.Nonnull;
+
 import net.pterodactylus.sone.core.*;
+import net.pterodactylus.sone.core.event.*;
 import net.pterodactylus.sone.fcp.*;
 import net.pterodactylus.sone.freenet.wot.*;
 import net.pterodactylus.sone.web.*;
@@ -59,7 +62,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
                        private final LoadingCache<String, Class<?>> classCache = CacheBuilder.newBuilder()
                                        .build(new CacheLoader<String, Class<?>>() {
                                                @Override
-                                               public Class<?> load(String key) throws Exception {
+                                               public Class<?> load(@Nonnull String key) throws Exception {
                                                        return SonePlugin.class.getClassLoader().loadClass(key);
                                                }
                                        });
@@ -207,8 +210,21 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
 
                /* start the web interface! */
                webInterface.start();
-               webInterface.setFirstStart(injector.getInstance(Key.get(Boolean.class, Names.named("FirstStart"))));
-               webInterface.setNewConfig(injector.getInstance(Key.get(Boolean.class, Names.named("NewConfig"))));
+
+               /* send some events on startup */
+               EventBus eventBus = injector.getInstance(EventBus.class);
+
+               /* first start? */
+               if (injector.getInstance(Key.get(Boolean.class, Names.named("FirstStart")))) {
+                       eventBus.post(new FirstStart());
+               } else {
+                       /* new config? */
+                       if (injector.getInstance(Key.get(Boolean.class, Names.named("NewConfig")))) {
+                               eventBus.post(new ConfigNotRead());
+                       }
+               }
+
+               eventBus.post(new Startup());
        }
 
        @VisibleForTesting