EmeraldEgg
在使用
  1. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), e.getMessage().replace("*", ""));  
复制代码

后服务端报错

版本: 1.18.1
  1. if (e.getMessage().startsWith("*")) {
  2.             if (!Main.list.contains(e.getSenderID())) {
  3.                 MiraiBot.getBot(e.getBotID()).getGroup(e.getGroupID()).sendMessage("[警告] 你没有权限这么做!");
  4.             } else {
  5.                 try {
  6.                     Bukkit.dispatchCommand(Bukkit.getConsoleSender(), e.getMessage().replace("*", ""));
  7.                     MiraiBot.getBot(e.getBotID()).getGroup(e.getGroupID()).sendMessage("[信息] 执行成功!");
  8.                 } catch (Exception a) {
  9.                     MiraiBot.getBot(e.getBotID()).getGroup(e.getGroupID()).sendMessage("[错误] 指令不正确!");
  10.                     a.printStackTrace();
  11.                 }
  12.             }
  13.         }
复制代码

此段代码

嘉晚饭,赢
Bukkit.dispatchCommand需要在主线程内执行

EmeraldEgg
嘉晚饭,赢 发表于 2022-1-30 19:45
Bukkit.dispatchCommand需要在主线程内执行

具体需要怎么做

嘉晚饭,赢
本帖最后由 嘉晚饭,赢 于 2022-1-30 19:50 编辑
  1. Bukkit.getScheduler().runTask(ExamplePlugin.instance, () -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), e.getMessage().replace("*", "")));
复制代码


ExamplePlugin.instance是你插件主类的实例