X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fmain%2FSonePlugin.java;h=ef9f05aac575f216948fd64db16c70e7dfbf17c9;hb=1ce940852c7e96a83233bcb706d0f87a1c655c54;hp=3f010f642a1f93cb467ebfcf5a14fcd3407aa2c2;hpb=8bd33b61d226641aad09285e97c156d4d6e25aed;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 3f010f6..ef9f05a 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -22,6 +22,8 @@ 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.*; @@ -60,7 +62,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr private final LoadingCache> classCache = CacheBuilder.newBuilder() .build(new CacheLoader>() { @Override - public Class load(String key) throws Exception { + public Class load(@Nonnull String key) throws Exception { return SonePlugin.class.getClassLoader().loadClass(key); } }); @@ -108,6 +110,9 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr /** The core. */ private Core core; + /** The event bus. */ + private EventBus eventBus; + /** The web interface. */ private WebInterface webInterface; @@ -208,12 +213,21 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr /* start the web interface! */ webInterface.start(); - webInterface.setNewConfig(injector.getInstance(Key.get(Boolean.class, Names.named("NewConfig")))); + + /* send some events on startup */ + eventBus = injector.getInstance(EventBus.class); /* first start? */ if (injector.getInstance(Key.get(Boolean.class, Names.named("FirstStart")))) { - injector.getInstance(EventBus.class).post(new 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 @@ -236,6 +250,9 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr */ @Override public void terminate() { + /* send shutdown event. */ + eventBus.post(new Shutdown()); + try { /* stop the web interface. */ webInterface.stop();