Move event sending into the command handler.
[xudocci.git] / src / main / java / net / pterodactylus / irc / Connection.java
index 82e2ea1..5345294 100644 (file)
@@ -369,15 +369,16 @@ public class Connection extends AbstractExecutionThreadService implements Servic
                                        new MessageHandler(eventBus, this, prefixHandler),
                                        new CtcpHandler(eventBus, this),
                                        new ChannelNickHandler(eventBus, this, prefixHandler),
-                                       new SimpleCommandHandler()
-                                                       .addCommand("431", (s, p) -> eventBus.post(
-                                                                       new NoNicknameGivenReceived(this)))
-                                                       .addCommand("NICK", (s, p) -> eventBus.post(
-                                                                       new NicknameChanged(this, s.get(),
-                                                                                       p.get(0))))
-                                                       .addCommand("JOIN", (s, p) -> eventBus.post(
-                                                                       new ChannelJoined(this, p.get(0),
-                                                                                       s.get()))),
+                                       new SimpleCommandHandler(eventBus)
+                                                       .addCommand("431",
+                                                                       (s, p) -> new NoNicknameGivenReceived(
+                                                                                       this))
+                                                       .addCommand("NICK",
+                                                                       (s, p) -> new NicknameChanged(this,
+                                                                                       s.get(), p.get(0)))
+                                                       .addCommand("JOIN",
+                                                                       (s, p) -> new ChannelJoined(this,
+                                                                                       p.get(0), s.get())),
                                        new MotdHandler(eventBus, this),
                                        new ChannelNotJoinedHandler(eventBus, this),
                                        new ConnectionEstablishHandler(eventBus, this),