diff --git a/BDSpyrunner.vcxproj b/BDSpyrunner.vcxproj index 2d424e1..b753e60 100644 --- a/BDSpyrunner.vcxproj +++ b/BDSpyrunner.vcxproj @@ -60,6 +60,7 @@ true true bedrock_server.dll + %(AdditionalLibraryDirectories) if exist ..\BDS\plugins ( diff --git a/BDSpyrunner.vcxproj.filters b/BDSpyrunner.vcxproj.filters index 8ea13cb..d3e7af6 100644 --- a/BDSpyrunner.vcxproj.filters +++ b/BDSpyrunner.vcxproj.filters @@ -127,20 +127,12 @@ 库文件 - - 库文件 - - - 库文件 - - - 库文件 - - - 库文件 - + + + + diff --git a/Example/_form.py b/Example/_form.py index acadf44..f87efda 100644 --- a/Example/_form.py +++ b/Example/_form.py @@ -1,4 +1,3 @@ -import mc import json diff --git a/Example/cmd.py b/Example/cmd.py new file mode 100644 index 0000000..1ece514 --- /dev/null +++ b/Example/cmd.py @@ -0,0 +1,16 @@ +from mc import * + + +def cb(p: CommandOrigin, result): + p.player.sendText(str(result)) + + +c = Command('test', 'test cmd', CommandPermissionLevel.Any) +c.mandatory('ssss', ParameterType.String) +c.mandatory( + 'aaa', ParameterType.SoftEnum, + c.setSoftEnum('asdasdasd', ['az,', 'azzzzz']) +) +c.overload(['ssss', 'aaa']) +c.setCallback(cb) +c.setup() \ No newline at end of file diff --git a/Example/mc.pyi b/Example/mc.pyi index 9153210..54d7e72 100644 --- a/Example/mc.pyi +++ b/Example/mc.pyi @@ -288,9 +288,24 @@ class Command: def setAlias(self, alias: str) -> bool: pass + def setSoftEnum(self, name, enums: list[str]) -> str: + pass + + def addSoftEnumValues(self, name, values: list[str]) -> bool: + pass + + def removeSoftEnumValues(self, name, values: list[str]) -> bool: + pass + + def getSoftEnumValues(self, name) -> list[str]: + pass + + def getSoftEnumNames(self) -> list[str]: + pass + def mandatory2( self, - name, + name: str, type: ParameterType, description: str = "", identifier: str = "", @@ -300,7 +315,7 @@ class Command: def mandatory( self, - name, + name: str, type: ParameterType, description: str = "", option=CommandParameterOption.None_ @@ -326,21 +341,6 @@ class Command: ) -> int: pass - def setSoftEnum(self, name, enums: list[str]) -> bool: - pass - - def addSoftEnumValues(self, name, values: list[str]) -> bool: - pass - - def removeSoftEnumValues(self, name, values: list[str]) -> bool: - pass - - def getSoftEnumValues(self, name) -> list[str]: - pass - - def getSoftEnumNames(self) -> list[str]: - pass - def overload(self, value=None) -> bool: pass @@ -473,6 +473,9 @@ class NBT: def asDouble(self) -> float: pass + def asString(self) -> str: + pass + def toBinary(self) -> bytes: pass @@ -954,6 +957,7 @@ def runCommandEx(cmd) -> tuple[str, bool]: def setListener(event, callback) -> bool: pass + # callback: (player: Player, result: dict[str, CommandResult]) -> None def registerCommand( name, desc, callback, perm=CommandPermissionLevel.GameMasters diff --git a/Example/pshop.py b/Example/pshop.py index 6de87a9..62f0219 100644 --- a/Example/pshop.py +++ b/Example/pshop.py @@ -14,7 +14,7 @@ pshop = {} -def str2json(data): +def str2json(data: str): jsondata = json.loads(data) return jsondata diff --git a/ModuleDef.cpp b/ModuleDef.cpp index e06bc9c..1b881e1 100644 --- a/ModuleDef.cpp +++ b/ModuleDef.cpp @@ -130,15 +130,15 @@ PYBIND11_EMBEDDED_MODULE(mc, mc_module) { .def("setEnum", &CommandClass::setEnum) .def("setAlias", &CommandClass::setAlias) - .def("mandatory2", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) - .def("mandatory", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "option"_a = None) - .def("optional2", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) - .def("optional", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "option"_a = None) .def("setSoftEnum", &CommandClass::setSoftEnum) .def("addSoftEnumValues", &CommandClass::addSoftEnumValues) .def("removeSoftEnumValues", &CommandClass::removeSoftEnumValues) .def("getSoftEnumValues", &CommandClass::getSoftEnumValues) .def("getSoftEnumNames", &CommandClass::getSoftEnumNames) + .def("mandatory2", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) + .def("mandatory", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "option"_a = None) + .def("optional2", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) + .def("optional", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "option"_a = None) .def("overload", py::overload_cast<>(&CommandClass::addOverload)) .def("overload", py::overload_cast&>(&CommandClass::addOverload)) .def("overload", py::overload_cast&&>(&CommandClass::addOverload)) diff --git a/SDK b/SDK index 1c93926..16bc6a1 160000 --- a/SDK +++ b/SDK @@ -1 +1 @@ -Subproject commit 1c93926ad8f4c3e21bcf2fdedc7b819aee581f30 +Subproject commit 16bc6a1ad708034513e8bf70fac9c69b85f6c399