diff --git a/src/main/java/org/kitteh/irc/client/library/defaults/listener/DefaultNickListener.java b/src/main/java/org/kitteh/irc/client/library/defaults/listener/DefaultNickListener.java index 4417a18f1..8613d97bb 100644 --- a/src/main/java/org/kitteh/irc/client/library/defaults/listener/DefaultNickListener.java +++ b/src/main/java/org/kitteh/irc/client/library/defaults/listener/DefaultNickListener.java @@ -58,21 +58,22 @@ public void nick(ClientReceiveCommandEvent event) { return; } boolean isSelf = ((User) event.getActor()).getNick().equals(this.getClient().getNick()); + String newNick = event.getParameters().get(0); Optional user = this.getTracker().getTrackedUser(((User) event.getActor()).getNick()); if (!user.isPresent()) { if (isSelf) { - this.getClient().setCurrentNick(event.getParameters().get(0)); + this.getClient().setCurrentNick(newNick); return; // Don't fail if NICK changes while not in a channel! } this.trackException(event, "NICK message sent for user not in tracked channels"); return; } User oldUser = user.get(); - this.getTracker().trackUserNickChange(user.get().getNick(), event.getParameters().get(0)); - User newUser = this.getTracker().getTrackedUser(((User) event.getActor()).getNick()).get(); + this.getTracker().trackUserNickChange(user.get().getNick(), newNick); + User newUser = this.getTracker().getTrackedUser(newNick).get(); this.fire(new UserNickChangeEvent(this.getClient(), event.getSource(), oldUser, newUser)); if (isSelf) { - this.getClient().setCurrentNick(event.getParameters().get(0)); + this.getClient().setCurrentNick(newNick); } } }