♻️ Get event bus only once
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 11 Dec 2019 17:32:47 +0000 (18:32 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 11 Dec 2019 18:47:29 +0000 (19:47 +0100)
src/main/java/net/pterodactylus/sone/main/SonePlugin.java

index a6ade6b..ca32537 100644 (file)
@@ -209,13 +209,16 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
                /* start the web interface! */
                webInterface.start();
 
+               /* send some events on startup */
+               EventBus 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")))) {
-                               injector.getInstance(EventBus.class).post(new ConfigNotRead());
+                               eventBus.post(new ConfigNotRead());
                        }
                }
        }