补图
1
1328189205 发布的帖子
-
RE: java版command相关问题
mirai
一.命令相关操作
1.创建一个类继承mirai api里的命令
public final class MyCommend extends JSimpleCommand { public static final MyCommend INSTANCE = new MyCommend(); private MyCommend() { super(Plugin.INSTANCE, "tell", new String[]{"s"}, Plugin.INSTANCE.getParentPermission()); this.setDescription("这是测试命令"); } @Handler public void onCommand(CommandSender sender, User target,String message) { target.sendMessage(message); } }
2.在onEnable()中注册命令
CommandManager.INSTANCE.registerCommand(MyCommend.INSTANCE,true);
3.就可在消息事件监听中执行命令了
CommandSenderOnMessage to = new MemberCommandSenderOnMessage(e); CommandManager.INSTANCE.executeCommand(to,e.getMessage(),false);