projects
/
xudocci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move nick changes into simple command handler.
[xudocci.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
irc
/
Connection.java
diff --git
a/src/main/java/net/pterodactylus/irc/Connection.java
b/src/main/java/net/pterodactylus/irc/Connection.java
index
9d9ef72
..
30344be
100644
(file)
--- a/
src/main/java/net/pterodactylus/irc/Connection.java
+++ b/
src/main/java/net/pterodactylus/irc/Connection.java
@@
-45,6
+45,7
@@
import net.pterodactylus.irc.connection.Handler;
import net.pterodactylus.irc.connection.MessageHandler;
import net.pterodactylus.irc.connection.MotdHandler;
import net.pterodactylus.irc.connection.PrefixHandler;
import net.pterodactylus.irc.connection.MessageHandler;
import net.pterodactylus.irc.connection.MotdHandler;
import net.pterodactylus.irc.connection.PrefixHandler;
+import net.pterodactylus.irc.connection.SimpleCommandHandler;
import net.pterodactylus.irc.event.ChannelJoined;
import net.pterodactylus.irc.event.ChannelLeft;
import net.pterodactylus.irc.event.ChannelTopic;
import net.pterodactylus.irc.event.ChannelJoined;
import net.pterodactylus.irc.event.ChannelLeft;
import net.pterodactylus.irc.event.ChannelTopic;
@@
-368,6
+369,12
@@
public class Connection extends AbstractExecutionThreadService implements Servic
new MessageHandler(eventBus, this, prefixHandler),
new CtcpHandler(eventBus, this),
new ChannelNickHandler(eventBus, this, prefixHandler),
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)))),
new MotdHandler(eventBus, this),
new ChannelNotJoinedHandler(eventBus, this),
new ConnectionEstablishHandler(eventBus, this),
new MotdHandler(eventBus, this),
new ChannelNotJoinedHandler(eventBus, this),
new ConnectionEstablishHandler(eventBus, this),
@@
-389,9
+396,7
@@
public class Connection extends AbstractExecutionThreadService implements Servic
}
/* 43x replies are for nick change errors. */
}
/* 43x replies are for nick change errors. */
- if (command.equals("431")) {
- eventBus.post(new NoNicknameGivenReceived(this, reply));
- } else if (command.equals("433")) {
+ if (command.equals("433")) {
if (!established.get()) {
nickname = nicknameChooser.getNickname();
connectionHandler.sendCommand("NICK", nickname);
if (!established.get()) {
nickname = nicknameChooser.getNickname();
connectionHandler.sendCommand("NICK", nickname);
@@
-399,10
+404,6
@@
public class Connection extends AbstractExecutionThreadService implements Servic
eventBus.post(new NicknameInUseReceived(this, reply));
}
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()));
/* channel stuff. */
} else if (command.equalsIgnoreCase("JOIN")) {
eventBus.post(new ChannelJoined(this, parameters.get(0), reply.source().get()));