From: David ‘Bombe’ Roden Date: Sun, 14 Apr 2013 09:47:21 +0000 (+0200) Subject: Send event when a client’s nickname changes. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d761d2e083fbbb4748bc56018f695b4971eb943e;p=xudocci.git Send event when a client’s nickname changes. --- diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index 9a2bcd5..f5b29b4 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -51,6 +51,7 @@ import net.pterodactylus.irc.event.ConnectionFailed; import net.pterodactylus.irc.event.DccAcceptReceived; import net.pterodactylus.irc.event.DccSendReceived; import net.pterodactylus.irc.event.MotdReceived; +import net.pterodactylus.irc.event.NicknameChanged; import net.pterodactylus.irc.event.NicknameInUseReceived; import net.pterodactylus.irc.event.NoNicknameGivenReceived; import net.pterodactylus.irc.event.PrivateMessageReceived; @@ -399,6 +400,10 @@ 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())); diff --git a/src/main/java/net/pterodactylus/irc/event/NicknameChanged.java b/src/main/java/net/pterodactylus/irc/event/NicknameChanged.java new file mode 100644 index 0000000..9b223dd --- /dev/null +++ b/src/main/java/net/pterodactylus/irc/event/NicknameChanged.java @@ -0,0 +1,74 @@ +/* + * XdccDownloader - NicknameChanged.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.irc.event; + +import net.pterodactylus.irc.Connection; +import net.pterodactylus.irc.Source; + +/** + * Notifies a listener that a client has changed its nickname. + * + * @author David ‘Bombe’ Roden + */ +public class NicknameChanged extends AbstractConnectionEvent { + + /** The client that changed its nickname. */ + private final Source client; + + /** The new nickname of the client. */ + private final String newNickname; + + /** + * Creates a new nickname changed event. + * + * @param connection + * The connection the event occured on + * @param client + * The client that changed its nickname + * @param newNickname + * The new nickname of the client + */ + public NicknameChanged(Connection connection, Source client, String newNickname) { + super(connection); + this.client = client; + this.newNickname = newNickname; + } + + // + // ACCESSORS + // + + /** + * Returns the client that changed its nickname. + * + * @return The client that changed its nickname + */ + public Source client() { + return client; + } + + /** + * Returns the new nickname of the client. + * + * @return The new nickname of the client + */ + public String newNickname() { + return newNickname; + } + +}