LiteLDev / LeviLamina

A lightweight, modular and versatile mod loader for Minecraft Bedrock Edition, formerly known as LiteLoaderBDS
https://levimc.org/software/levilamina
GNU Lesser General Public License v3.0
1.14k stars 117 forks source link

ob.getScore(target)无法正确获取对应分数 #626

Closed Hesitate-P closed 2 years ago

Hesitate-P commented 2 years ago

异常模块

ScriptEngine(脚本引擎)

操作系统

Windows 11

LiteLoader版本

2.4.2

BDS版本

1.19.10

发生了什么?

在使用ob.getScore(target)时无法正确返回对应分数

复现此问题的步骤

1.随意注册一个监听 2.使用mc.getScoreObjective(name)获得一个已存在的计分板对象 3.使用ob.getScore(target)获取玩家的分数 4.如果log此时玩家的分数,你会发现输出为”0“

有关的日志/输出

[XXX] 0
(无报错

插件列表

ll list
23:23:50 INFO [Server] Plugin Lists [5]
23:23:50 INFO [Server] - LLMoney [v2.4.0] (LLMoney.dll)
23:23:50 INFO [Server]   EconomyCore for LiteLoaderBDS
23:23:50 INFO [Server] - ScriptEngine-Lua [v2.4.2] (LiteLoader.Lua.dll)
23:23:50 INFO [Server]   Lua ScriptEngine for LiteLoaderBDS
23:23:50 INFO [Server] - Dungeon-2.js [v1.0.0] (Dungeon-2.js)
23:23:50 INFO [Server]   Dungeon-2.js
23:23:50 INFO [Server] - ScriptEngine-Js [v2.4.2] (LiteLoader.Js.dll)
23:23:50 INFO [Server]   Javascript ScriptEngine for LiteLoaderBDS
23:23:50 INFO [Server] - Dungeon-1.js [v1.0.0] (Dungeon-1.js)
23:23:50 INFO [Server]   Dungeon-1.js
Hesitate-P commented 2 years ago

此处有一份测试代码

mc.listen("onChat",function(player){
    let play_hnjd = mc.getScoreObjective("play_hnjd")
    if(play_hnjd == null){
        play_hnjd = mc.newScoreObjective("play_hnjd","play_hnjd")
    }
    if(play_hnjd.getScore(player) == 0){
        play_hnjd.addScore(player,1)
    }
    log(play_hnjd.getScore(player))
})
Jasonzyt commented 2 years ago

Fixed in 1e9d7ff Scoreboard这一块确实挺乱的,找机会重构一下吧