Skip to content

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

@Hurry1027

Description

@Hurry1027

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
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] 断开了连接 | 在线时长 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions