Skip to content
New issue

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

插件加载抛出异常 Function importClass must be called with a class #10

Closed
Taifendesune opened this issue Oct 16, 2021 · 5 comments

Comments

@Taifendesune
Copy link

环境:

  • mirai-console: 2.8.0-M1
  • mirai-console-terminal: 2.8.0-M1
  • mirai-core-all: 2.8.0-M1
  • mirai-js: 2.0-RC-dev1

代码为示例代码:

importClass(net.mamoe.mirai.event.GlobalEventChannel);
importClass(net.mamoe.mirai.event.events.BotOnlineEvent);
importPackage(net.mamoe.mirai)

let bot = null;
let listener = GlobalEventChannel.INSTANCE.subscribeAlways(BotOnlineEvent, (event) => {
    logger.info("Bot " + event.getBot() + " is now online!");
    bot = event.getBot();
});

异常信息:
image

2021-10-17 01:50:59 E/org.itxtech.miraijs.MiraiJs: Error while loading studychat.zip: org.mozilla.javascript.EvaluatorException: Function importClass must be called with a class; had "[JavaPackage com.stardust.autojs.core.http.MutableOkHttp]" instead. (importOkHttpLib#12)

代码改为以下内容报同样错误:

// importClass(net.mamoe.mirai.event.GlobalEventChannel);
// importClass(net.mamoe.mirai.event.events.BotOnlineEvent);
// importPackage(net.mamoe.mirai)

let bot = null;
let listener = net.mamoe.mirai.event.GlobalEventChannel.INSTANCE.subscribeAlways(
  mirai.event.events.BotOnlineEvent,
  (event) => {
    logger.info("Bot " + event.getBot() + " is now online!");
    bot = event.getBot();
  }
);
@Taifendesune
Copy link
Author

以上为 main.js 中代码

@StageGuard
Copy link
Collaborator

运行环境?

@Taifendesune
Copy link
Author

运行环境?
系统:
CentOS Linux release 7.3.1611 (Core)
Java:
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment Temurin-11.0.12+7 (build 11.0.12+7)
OpenJDK 64-Bit Server VM Temurin-11.0.12+7 (build 11.0.12+7, mixed mode)

@DomeenoH
Copy link

遇到了同样的问题

@StageGuard
Copy link
Collaborator

经发现使用 mcl 启动时脚本环境无法找到 net.mamoe.mirai 包,请使用原始方式启动:

java -cp "./libs/*" net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants