LegacyScriptEngine icon indicating copy to clipboard operation
LegacyScriptEngine copied to clipboard

[Bug]: onLeft使用其他插件api,stop关服会报错

Open Hurry1027 opened this issue 5 months ago • 2 comments

Describe the bug

导入GMLIB或Pland api后,如果onLeft事件中有外部api的调用,那么stop关服会报错。 显示插件正在禁用 test v1.0.0,但日志末尾还会有插件onLeft事件中的输出。 ll.onUnload()没有在关服时触发,所以无法规避此报错。 倒是不影响正常功能,但有的插件会有大量报错信息。

23:44:31.240 INFO [test] setInterval: true 23:44:31.752 INFO [test] setInterval: true 23:44:32.252 INFO [test] setInterval: true 23:44:32.750 INFO [test] setInterval: true 23:44:32.967 INFO [Server] Server stop requested. 23:44:33.029 INFO [Server] Stopping server... 23:44:33.076 INFO [LeviLamina] 正在禁用模组…… ... 23:44:33.076 INFO [LeviLamina] 正在禁用 test v1.0.0 23:44:33.076 INFO [LeviLamina] 正在禁用 WnBagBackup v1.0.0 ... 23:44:33.076 INFO [LeviLamina] 正在禁用 GMLIB-LegacyRemoteCallApi v1.2.0 23:44:33.076 INFO [LeviLamina] 正在禁用 legacy-script-engine-nodejs v0.12.0 23:44:33.076 INFO [LeviLamina] 正在禁用 iListenAttentively-LseExport v0.1.6 23:44:33.076 INFO [LeviLamina] 正在禁用 legacy-script-engine-quickjs v0.0.0+c60e0be 23:44:33.076 INFO [LeviLamina] 正在禁用 legacy-script-engine-lua v0.12.0 23:44:37.563 INFO [LeviLamina] 正在禁用 GMLIB v1.3.0+1d04fac 23:44:38.025 INFO [LeviLamina] 正在禁用 LegacyRemoteCall v0.12.0 23:44:38.025 INFO [LeviLamina] 正在禁用 LegacyMoney v0.12.0 23:44:38.025 INFO [LeviLamina] 正在禁用 LegacyParticleAPI v0.12.0 23:44:38.025 INFO [LeviLamina] 正在禁用 BedrockServerClientInterface v0.1.6 23:44:38.026 INFO [LeviLamina] 正在禁用 iListenAttentively v0.6.0 23:44:38.026 INFO [LeviLamina] 正在禁用 Glacie v3.3.2 23:44:38.047 INFO [Server] Player disconnected: Wn1027, xuid: 2535427849428692, pfid: 118bd779cc337325 23:44:38.048 ERROR [legacy-script-engine-quickjs] Fail to import! Function [GMLIB_API::hasPlayerNbt] has not been exported! 23:44:38.048 ERROR [legacy-script-engine-quickjs] In plugin <WnBagBackup> 23:44:38.048 ERROR [legacy-script-engine-quickjs] Fail to import! Function [GMLIB_API::hasPlayerNbt] has not been exported! 23:44:38.048 ERROR [legacy-script-engine-quickjs] In plugin 23:44:38.048 INFO [test] onLeft: undefined 23:44:38.048 INFO [flysteve] <Wn1027> 断开了连接 | 在线时长 0.18分钟 Quit correctly

To Reproduce

quickjs 插件,玩家进服后,控制台stop关服

let GMLIB_MC;
mc.listen("onServerStarted", ()=>{
    try{
        GMLIB_MC = require("./GMLIB-LegacyRemoteCallApi/lib/GMLIB_API-JS").Minecraft;
    }catch(e){
        logger.error('需要前置插件: GMLIB-LegacyRemoteCallApi');
    }
});

mc.listen("onLeft", (pl)=>{
    if (GMLIB_MC == null){return;}
    log('onLeft: '+ GMLIB_MC.hasPlayerNbt(pl.uuid));
});
setInterval(()=>{
    if (GMLIB_MC == null){return;}
    log('setInterval: '+ GMLIB_MC.hasPlayerNbt(mc.getOnlinePlayers()[0]?.uuid??''));
}, 500);

ll.onUnload(()=>{
    GMLIB_MC = null;
    log('test unloaded!!!!!')
});
{
    "name": "test",
    "entry": "test.js",
    "type": "lse-quickjs",
    "author": "Wn1027",
    "description": "t",
    "version": "1.0.0",
    "dependencies": [
        {
            "name": "GMLIB-LegacyRemoteCallApi"
        },
        {
            "name": "legacy-script-engine-quickjs"
        }
    ]
}

Expected behavior

修复此问题,或者有没有规避此报错的一般性方法

Screenshots

No response

Platform

Windows 10

BDS Version

1.21.80

LeviLamina Version

1.3.1

LegacyScriptEngine Version

0.12.0

Additional context

No response

Hurry1027 avatar Jul 08 '25 16:07 Hurry1027

ll.onUnload 并不能解决你的问题,因为 GMLIB-LegacyRemoteCallApi 卸载的时候 test 并未卸载。 建议的解决方式是给mod添加依赖或者可选依赖,ll会根据依赖来按顺序加载和卸载插件,被依赖的插件先加载,后卸载

xiaoqch avatar Jul 09 '25 12:07 xiaoqch

ll.onUnload 并不能解决你的问题,因为 GMLIB-LegacyRemoteCallApi 卸载的时候 test 并未卸载。 建议的解决方式是给mod添加依赖或者可选依赖,ll会根据依赖来按顺序加载和卸载插件,被依赖的插件先加载,后卸载

复现代码已经在manifest.json的依赖中包含了GMLIB-LegacyRemoteCallApi,我下载替换了刚刚构建的lse-quickjs版本(0.0.0+fa4f42d),目前问题还存在

Hurry1027 avatar Jul 09 '25 14:07 Hurry1027