twoone-3 / BDSpyrunner

support python in liteloderbds
GNU General Public License v3.0
56 stars 18 forks source link

【Pyr 1.9.5】registerCommand API callback无效 #26

Closed Moxiner closed 2 years ago

Moxiner commented 2 years ago

控制台输出

[03:48:08 Info][Server] Player connected: Moxiners, xuid: 2535416022XXXX [03:48:24 Info][Test] onCmdTest [03:49:01 Info][Server] Player disconnected: Moxiners, xuid: 2535416022XXXX

游戏输出

onCmd

建议

[-] 删除registerCommand的callback,或 默认callback = None!

这是我写的Test.py,可以作为测试使用

import time
import mc
PluginName = "Test"
class PrintLog:
    '''标准化输出'''   
    def GetTime():
        '''获取当前时间'''
        return time.strftime("%H:%M:%S")

    def InfoLog(concent:str):
        '''输出Info通知'''
        mc.logout(f"\033[0m[{PrintLog.GetTime()} Info][{PluginName}] {concent}\n\033[0m")

    def WarmLog(concent:str):
        '''输出Warm警告'''
        mc.logout(f"\033[1;33m[{PrintLog.GetTime()} Info][{PluginName}] {concent}\n\033[0m")

    def ErroeLog(concent:str):
        '''输出Erroe错误'''
        mc.logout(f"\033[1;31m[{PrintLog.GetTime()} Info][{PluginName}] {concent}\n\033[0m")

def RegTest(e):
    player = e["Player"]
    PrintLog.InfoLog("regTest")
    player.sendText("regTest")

def onCmdTest(e):
    player = e["Player"]
    PrintLog.InfoLog("onCmdTest")
    player.sendText("onCmdTest")
# mc.setListener("onPlayCmd",Test)
mc.registerCommand("test",RegTest,"测试")
mc.setListener("onPlayerCmd",onCmdTest)
twoone-3 commented 2 years ago

已修复