m.onServer(server, params);
}
- m.on(source, params);
+ if (server != null || user != null)
+ {
+ /*
+ * Message class will take care of backwards compatibility
+ * for stuff still using redundant checks.
+ */
+ m.on(server, user, params);
+ }
+ else
+ {
+ m.on(source, params);
+ }
}
public static void run() throws InterruptedException
public void onServer(Server source, String[] params) { }
public void on(String source, String[] params) { }
+ /*
+ * handle a message that could come from either UID or SID and matched
+ * either one of them.
+ */
+ public void on(Server server, User user, String[] params) {
+ /* default implementation for backwards compat */
+ if (user != null && server == null)
+ {
+ on(user.getNick(), params);
+ }
+ else if (server != null && user == null)
+ {
+ on(server.getName(), params);
+ }
+ else
+ {
+ /*
+ * both server and user are set, this shouldn't be possible
+ * unless something got changed in AcidCore. or both are null
+ * which shouldn't be possible either.
+ */
+ throw new RuntimeException("both server and user are not null or both are null");
+ }
+
+ }
+
private static HashMap<String, Message> messages;
public static Message findMessage(String name)
super("TMODE");
}
- /* common handler */
- private void handleTsModeChange(String setBy, String[] params) {
+ @Override
+ public void on(Server server, User user, String[] params)
+ {
Channel chan = Channel.findChannel(params[1]);
if (chan == null || shouldDropTsMessage(chan.getTS(), params[0]))
return;
for (int i = 3; i < params.length; i++)
modes += " " + params[i];
- Acidictive.onChanMode(setBy, chan, modes);
+ Acidictive.onChanMode(
+ user != null ? user.getNick() : server.getName(),
+ chan,
+ modes);
if (chan.size() == 0 && !chan.hasMode('z'))
chan.destroy();
}
-
- /*
- * old implementation handled these in ::on which is redundant since
- * AcidCore::processMessage already does these lookups, no need to
- * do them again.
- */
-
- @Override
- public void onUser(User user, String[] params)
- {
- handleTsModeChange(user.getNick(), params);
- }
-
- @Override
- public void onServer(Server server, String[] params)
- {
- handleTsModeChange(server.getName(), params);
- }
}
\ No newline at end of file