]> jfr.im git - irc/rizon/acid.git/commitdiff
acid: change source of Message.on() back to previous behavior
authorAdam <redacted>
Tue, 19 Dec 2017 23:03:32 +0000 (18:03 -0500)
committerAdam <redacted>
Tue, 19 Dec 2017 23:03:32 +0000 (18:03 -0500)
acid/src/main/java/net/rizon/acid/core/AcidCore.java
acid/src/main/java/net/rizon/acid/core/Message.java
acid/src/main/java/net/rizon/acid/messages/TMode.java

index cd2a12bfc700e35c8d213e7c859d13616427d499..9cba6176d24080dff7bcfc3b9ecd36d1f27bb82c 100644 (file)
@@ -128,18 +128,7 @@ public abstract class AcidCore
                        m.onServer(server, 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);
-               }
+               m.on(source, params);
        }
 
        public static void run() throws InterruptedException
index 61b71902ca5b2da99b71dceed412d6e2c7451367..708400b46bde5ec624077a841681d7cc56f28d95 100644 (file)
@@ -51,32 +51,6 @@ public abstract class Message
        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)
index 83c4212addaff9f9a7b8b27c47c17f64ac5d5958..925cfe5d8f33fee16396026d8680866a479f1d69 100644 (file)
@@ -4,7 +4,6 @@
  * Support for TS6 TMODE.
  * Format is :<SID|UID> TMODE <TS> <CHANNAME> <MODESTRING>
  */
-
 package net.rizon.acid.messages;
 
 import net.rizon.acid.core.Acidictive;
@@ -24,23 +23,40 @@ public class TMode extends Message
                super("TMODE");
        }
 
-       @Override
-       public void on(Server server, User user, String[] params)
+       private void run(String source, String[] params)
        {
                Channel chan = Channel.findChannel(params[1]);
                if (chan == null || shouldDropTsMessage(chan.getTS(), params[0]))
+               {
                        return;
+               }
 
                String modes = params[2];
                for (int i = 3; i < params.length; i++)
+               {
                        modes += " " + params[i];
+               }
 
                Acidictive.onChanMode(
-                       user != null ? user.getNick() : server.getName(),
+                       source,
                        chan,
                        modes);
 
                if (chan.size() == 0 && !chan.hasMode('z'))
+               {
                        chan.destroy();
+               }
+       }
+
+       @Override
+       public void onUser(User source, String[] params)
+       {
+               run(source.getNick(), params);
+       }
+
+       @Override
+       public void onServer(Server source, String[] params)
+       {
+               run(source.getName(), params);
        }
-}
\ No newline at end of file
+}