MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    Java如何对其他模块发出指令?

    开发交流
    2
    4
    423
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 2
      250king last edited by

      因为要做一个门户站点,方便我的客户自行管理机器人,所以把机器人的每个功能都分了模块,由一个总模块来接受MQ队列发来的指令,并控制其他模块。但由于过于萌新,不知道怎么用Java来给模块发指令,求大神帮助!屏幕截图 2021-06-05 131132.png

      1 Reply Last reply Reply Quote 1
      • Karlatemp
        Karlatemp last edited by

        请问你说的 模块 具体指的是什么,拥有什么功能

        CommandSender 的获取可以在 CommandSender.kt 中找到完善的注释和方法定义

        并且推荐使用 kotlin 获得更好的使用体验

        2 1 Reply Last reply Reply Quote 0
        • 2
          250king @Karlatemp last edited by 250king

          @Karlatemp
          大概是这样子(机器人部分)
          未命名绘图.png

          1 Reply Last reply Reply Quote 0
          • Karlatemp
            Karlatemp last edited by Karlatemp

            按照你的图示你其实没必要经过命令,你可以直接调用你执行的相关方法,而且看你的结构似乎没有涉及到命令相关的内容

            如果你有使用命令的需要可以参考以下结构

            public class Cmd extends ***Command {
            public static void run(CommandSender sender, .......){}
            }
            
            public class Processor {
            public static void ....() {
            
            ....
            Cmd.run(CommandSender.from(....) / .of(...), ....)
            ....
            
            }
            }
            
            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact