We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
目前当多个主指令名相同的CompositeCommand注册时,不论override真假,最终只有唯一的CompositeCommand(中的SubCommand)生效。
设想需求是一个XX助手插件需要如下指令集:
XX助手插件
按照目前的情况,只能把以上所有SubCommand放在同一个CompositeCommand,其用XX助手作为主指令名。
XX助手
理想的情况是编写BilibiliCommand、WeiboCommand……,多个CompositeCommand分别拥有各自的SubCommand,均用XX助手作为主指令名。注册后,这些CompositeCommand的SubCommand均生效。
The text was updated successfully, but these errors were encountered:
在内部实现上是先匹配主指令名再由 CompositeCommand 实例去处理子指令,不容易实现你所提议的
Sorry, something went wrong.
我现在通过如下方式间接实现了。不过ParentCommand里需要人工编写数个方法(人工编写委托关系),不知是否可以进一步优化成自动化。
MyPlugin.onEnable() { // 只注册ParentCommand CommandManager.INSTANCE.registerCommand(new ParentCommand(), false); } public class ParentCommand extends CompositeCommand { BilibiliCommand bilibiliCommand = new BilibiliCommand(); WeiboiCommand weiboiCommand = new WeiboiCommand(); public ParentCommand() { super("XX助手") } @SubCommand("查询b站动态") public void bilibiliCommandWork(CommandSender sender) { bilibiliCommand.work(sender); } @SubCommand("查询微博动态") public void weiboiCommandWork(CommandSender sender) { weiboiCommand.work(sender); } } // 其实可以不extends CompositeCommand, 因为不会注册到CommandManager public class BilibiliCommand extends CompositeCommand { public BilibiliCommand() { // 无用的PrimaryName, 因为不会注册到CommandManager super("uselessName0") } // 其实可以不@SubCommand, 因为不会注册到CommandManager @SubCommand("查询b站动态") public void work(CommandSender sender) { // do something } } public class WeiboCommand extends CompositeCommand { public WeiboCommand() { super("uselessName1") } @SubCommand("查询微博动态") public void work(CommandSender sender) { // do something } }
Successfully merging a pull request may close this issue.
目前当多个主指令名相同的CompositeCommand注册时,不论override真假,最终只有唯一的CompositeCommand(中的SubCommand)生效。
设想需求是一个
XX助手插件
需要如下指令集:按照目前的情况,只能把以上所有SubCommand放在同一个CompositeCommand,其用
XX助手
作为主指令名。理想的情况是编写BilibiliCommand、WeiboCommand……,多个CompositeCommand分别拥有各自的SubCommand,均用
XX助手
作为主指令名。注册后,这些CompositeCommand的SubCommand均生效。The text was updated successfully, but these errors were encountered: