Move nick changes into simple command handler.
[xudocci.git] / src / main / java / net / pterodactylus / irc / Connection.java
index d12cc77..30344be 100644 (file)
@@ -370,8 +370,11 @@ public class Connection extends AbstractExecutionThreadService implements Servic
                                        new CtcpHandler(eventBus, this),
                                        new ChannelNickHandler(eventBus, this, prefixHandler),
                                        new SimpleCommandHandler()
-                                                       .addCommand("431", (parameters) -> eventBus.post(
-                                                                       new NoNicknameGivenReceived(this))),
+                                                       .addCommand("431", (s, p) -> eventBus.post(
+                                                                       new NoNicknameGivenReceived(this)))
+                                                       .addCommand("NICK", (s, p) -> eventBus.post(
+                                                                       new NicknameChanged(this, s.get(),
+                                                                                       p.get(0)))),
                                        new MotdHandler(eventBus, this),
                                        new ChannelNotJoinedHandler(eventBus, this),
                                        new ConnectionEstablishHandler(eventBus, this),
@@ -401,10 +404,6 @@ public class Connection extends AbstractExecutionThreadService implements Servic
                                                eventBus.post(new NicknameInUseReceived(this, reply));
                                        }
 
-                               /* client stuff. */
-                               } else if (command.equalsIgnoreCase("NICK")) {
-                                       eventBus.post(new NicknameChanged(this, reply.source().get(), parameters.get(0)));
-
                                /* channel stuff. */
                                } else if (command.equalsIgnoreCase("JOIN")) {
                                        eventBus.post(new ChannelJoined(this, parameters.get(0), reply.source().get()));