From b6505c4d0f4fbc2bf19cc8b6030062bca6d180dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 16 Oct 2014 22:28:49 +0200 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20expose=20the=20complete=20reply?= =?utf8?q?=20object=20from=20the=20notice=20event.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/irc/Connection.java | 2 +- .../irc/event/PrivateNoticeReceived.java | 43 +++++----------------- .../java/net/pterodactylus/xdcc/core/Core.java | 2 +- 3 files changed, 11 insertions(+), 36 deletions(-) diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index 15bb319..f6b7913 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -416,7 +416,7 @@ public class Connection extends AbstractExecutionThreadService implements Servic /* CTCP! */ handleCtcp(reply.source().get(), message); } else if (!prefixHandler.isChannel(recipient)) { - eventBus.post(new PrivateNoticeReceived(this, reply)); + eventBus.post(new PrivateNoticeReceived(this, reply.source().get(), message)); } else { eventBus.post(new ChannelNoticeReceived(this, reply.source().get(), recipient, message)); } diff --git a/src/main/java/net/pterodactylus/irc/event/PrivateNoticeReceived.java b/src/main/java/net/pterodactylus/irc/event/PrivateNoticeReceived.java index afb6acc..4089fcb 100644 --- a/src/main/java/net/pterodactylus/irc/event/PrivateNoticeReceived.java +++ b/src/main/java/net/pterodactylus/irc/event/PrivateNoticeReceived.java @@ -18,53 +18,28 @@ package net.pterodactylus.irc.event; import net.pterodactylus.irc.Connection; -import net.pterodactylus.irc.Reply; +import net.pterodactylus.irc.Source; /** * Notifies a listener that a notice was received. * * @author David ‘Bombe’ Roden */ -public class PrivateNoticeReceived extends AbstractReplyEvent { +public class PrivateNoticeReceived extends AbstractConnectionEvent { - /** The target of the notice. */ - private final String target; - - /** The text of the notice. */ + private final Source source; private final String text; - /** - * Creates a new notice received event. - * - * @param connection - * The connection the event occured on - * @param reply - * The reply that caused the event - */ - public PrivateNoticeReceived(Connection connection, Reply reply) { - super(connection, reply); - this.target = reply.parameters().get(0); - this.text = reply.parameters().get(1); + public PrivateNoticeReceived(Connection connection, Source source, String text) { + super(connection); + this.source = source; + this.text = text; } - // - // ACCESSORS - // - - /** - * Returns the target of the notice. - * - * @return The target of the notice - */ - public String target() { - return target; + public Source source() { + return source; } - /** - * Returns the text of the notice. - * - * @return The text of the notice - */ public String text() { return text; } diff --git a/src/main/java/net/pterodactylus/xdcc/core/Core.java b/src/main/java/net/pterodactylus/xdcc/core/Core.java index 8d983d5..509d30e 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -730,7 +730,7 @@ public class Core extends AbstractExecutionThreadService { return; } - eventBus.post(new GenericMessage(String.format("Notice from %s (%s): %s", privateNoticeReceived.reply().source().get(), network.get(), privateNoticeReceived.text()))); + eventBus.post(new GenericMessage(String.format("Notice from %s (%s): %s", privateNoticeReceived.source(), network.get(), privateNoticeReceived.text()))); } /** -- 2.7.4