From 4062956dbf9a40bb1538dacf93c84e2dbfe3b2e2 Mon Sep 17 00:00:00 2001 From: STYLE-STARS <485429738@qq.com> Date: Sun, 22 Mar 2026 20:24:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0[=E5=89=8D=E7=BD=AE=5F?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=8F=92=E4=BB=B6=E5=8A=9F=E8=83=BD=E5=BA=93?= =?UTF-8?q?],=20[=E6=8E=A7=E5=88=B6=E5=8F=B0=E6=89=A7=E8=A1=8CMC=E6=8C=87?= =?UTF-8?q?=E4=BB=A4]=E4=BB=A5=E9=80=82=E9=85=8DSendAiCmdWithResp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__init__.py" | 8 +++-- .../datas.json" | 2 +- .../__init__.py" | 33 +++++++++++++++---- .../datas.json" | 6 ++-- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git "a/\345\211\215\347\275\256_\345\237\272\346\234\254\346\217\222\344\273\266\345\212\237\350\203\275\345\272\223/__init__.py" "b/\345\211\215\347\275\256_\345\237\272\346\234\254\346\217\222\344\273\266\345\212\237\350\203\275\345\272\223/__init__.py" index 2429e065..f43ebbdb 100644 --- "a/\345\211\215\347\275\256_\345\237\272\346\234\254\346\217\222\344\273\266\345\212\237\350\203\275\345\272\223/__init__.py" +++ "b/\345\211\215\347\275\256_\345\237\272\346\234\254\346\217\222\344\273\266\345\212\237\350\203\275\345\272\223/__init__.py" @@ -2,7 +2,11 @@ import uuid import threading from tooldelta import Plugin, constants, utils, Chat, Player, plugin_entry -from tooldelta.constants.netease import PYRPC_OP_SEND + +try: + from tooldelta.mc_bytes_packet.py_rpc import PYRPC_OP_SEND +except ImportError: + from tooldelta.constants.netease import PYRPC_OP_SEND # type: ignore if 0: from tooldelta.internal.types import Packet_CommandOutput @@ -16,7 +20,7 @@ def find_key_from_value(dic, val): class BasicFunctionLib(Plugin): - version = (0, 0, 12) + version = (0, 0, 13) name = "基本插件功能库" author = "SuperScript" description = "提供额外的方法用于获取游戏数据" diff --git "a/\345\211\215\347\275\256_\345\237\272\346\234\254\346\217\222\344\273\266\345\212\237\350\203\275\345\272\223/datas.json" "b/\345\211\215\347\275\256_\345\237\272\346\234\254\346\217\222\344\273\266\345\212\237\350\203\275\345\272\223/datas.json" index 6eb9507a..e3410240 100644 --- "a/\345\211\215\347\275\256_\345\237\272\346\234\254\346\217\222\344\273\266\345\212\237\350\203\275\345\272\223/datas.json" +++ "b/\345\211\215\347\275\256_\345\237\272\346\234\254\346\217\222\344\273\266\345\212\237\350\203\275\345\272\223/datas.json" @@ -1,6 +1,6 @@ { "author": "SuperScript", - "version": "0.0.12", + "version": "0.0.13", "description": "所有使用基本组件API的插件的前置", "limit_launcher": null, "pre-plugins": {}, diff --git "a/\346\216\247\345\210\266\345\217\260\346\211\247\350\241\214MC\346\214\207\344\273\244/__init__.py" "b/\346\216\247\345\210\266\345\217\260\346\211\247\350\241\214MC\346\214\207\344\273\244/__init__.py" index 486474d2..9c2983d1 100644 --- "a/\346\216\247\345\210\266\345\217\260\346\211\247\350\241\214MC\346\214\207\344\273\244/__init__.py" +++ "b/\346\216\247\345\210\266\345\217\260\346\211\247\350\241\214MC\346\214\207\344\273\244/__init__.py" @@ -5,17 +5,13 @@ class ConsoleCommands(Plugin): name = "控制台执行MC指令" author = "SuperScript" - version = (0, 0, 5) + version = (0, 0, 6) def __init__(self, frame: Frame): self.frame = frame self.game_ctrl = frame.get_game_control() - self.ListenPreload(self.on_def) self.ListenActive(self.on_inject) - def on_def(self): - self.funclib = self.GetPluginAPI("基本插件功能库") - def on_inject(self): self.frame.add_console_cmd_trigger( ["ws/"], "[指令]", "执行WS指令", self.SendWSCmdOnConsole @@ -59,7 +55,32 @@ def SendWOCmdOnConsole(self, cmd): self.game_ctrl.sendwocmd(" ".join(cmd)) def SendAICmdOnConsole(self, cmd): - self.funclib.sendaicmd(" ".join(cmd)) + try: + result = self.game_ctrl.sendaicmd_with_resp(" ".join(cmd), 5) + except IndexError: + Print.print_err("缺少指令参数") + return + try: + if (result.OutputMessages[0].Message == "commands.generic.syntax") | ( + result.OutputMessages[0].Message == "commands.generic.unknown" + ): + Print.print_err("未知的MC指令, 可能是指令格式有误") + else: + jso = json.dumps( + result.as_dict["OutputMessages"], indent=2, ensure_ascii=False + ) + if not result.SuccessCount: + Print.print_war(f"指令执行失败:\n{jso}") + else: + Print.print_suc(f"指令执行成功: \n{jso}") + except IndexError: + if result.SuccessCount: + jso = json.dumps( + result.as_dict["OutputMessages"], indent=2, ensure_ascii=False + ) + Print.print_suc(f"指令执行成功: \n{jso}") + except TimeoutError: + Print.print_err("[超时] 指令获取结果返回超时") entry = plugin_entry(ConsoleCommands) diff --git "a/\346\216\247\345\210\266\345\217\260\346\211\247\350\241\214MC\346\214\207\344\273\244/datas.json" "b/\346\216\247\345\210\266\345\217\260\346\211\247\350\241\214MC\346\214\207\344\273\244/datas.json" index 9fb15455..76961a3a 100644 --- "a/\346\216\247\345\210\266\345\217\260\346\211\247\350\241\214MC\346\214\207\344\273\244/datas.json" +++ "b/\346\216\247\345\210\266\345\217\260\346\211\247\350\241\214MC\346\214\207\344\273\244/datas.json" @@ -1,11 +1,9 @@ { "author": "SuperScript", - "version": "0.0.5", + "version": "0.0.6", "description": "可以在控制台让机器人执行特殊指令等, 还可以发送魔法(AI)指令\n - ws/: 发送 WebSocket 指令\n - ai/ 发送 ai 指令", "limit_launcher": null, - "pre-plugins": { - "基本插件功能库": "0.0.12" - }, + "pre-plugins": {}, "plugin-type": "classic", "plugin-id": "控制台执行MC指令", "enabled": true