Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.

Commit 3515e83

Browse files
author
twoone3
committed
2.0.6更新
- 修复mc.pyi中setSoftEnum的返回值错误 - 新增cmd.py注册命令样例
1 parent b32e6d1 commit 3515e83

File tree

8 files changed

+48
-36
lines changed

8 files changed

+48
-36
lines changed

BDSpyrunner.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<OptimizeReferences>true</OptimizeReferences>
6161
<GenerateDebugInformation>true</GenerateDebugInformation>
6262
<DelayLoadDLLs>bedrock_server.dll</DelayLoadDLLs>
63+
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
6364
</Link>
6465
<PostBuildEvent>
6566
<Command>if exist ..\BDS\plugins (

BDSpyrunner.vcxproj.filters

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,12 @@
127127
<Library Include="Lib\python37.lib">
128128
<Filter>库文件</Filter>
129129
</Library>
130-
<Library Include="SDK\Lib\LiteLoader.lib">
131-
<Filter>库文件</Filter>
132-
</Library>
133-
<Library Include="SDK\Lib\SymDBHelper.lib">
134-
<Filter>库文件</Filter>
135-
</Library>
136-
<Library Include="SDK\Lib\bedrock_server_api.lib">
137-
<Filter>库文件</Filter>
138-
</Library>
139-
<Library Include="SDK\Lib\bedrock_server_var.lib">
140-
<Filter>库文件</Filter>
141-
</Library>
142130
<Library Include="SDK\Lib\bedrock_server_var.lib" />
143131
<Library Include="SDK\Lib\bedrock_server_api.lib" />
132+
<Library Include="SDK\Lib\bedrock_server_api.lib" />
133+
<Library Include="SDK\Lib\bedrock_server_var.lib" />
134+
<Library Include="SDK\Lib\LiteLoader.lib" />
135+
<Library Include="SDK\Lib\SymDBHelper.lib" />
144136
</ItemGroup>
145137
<ItemGroup>
146138
<None Include=".clang-format" />

Example/_form.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import mc
21
import json
32

43

Example/cmd.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from mc import *
2+
3+
4+
def cb(p: CommandOrigin, result):
5+
p.player.sendText(str(result))
6+
7+
8+
c = Command('test', 'test cmd', CommandPermissionLevel.Any)
9+
c.mandatory('ssss', ParameterType.String)
10+
c.mandatory(
11+
'aaa', ParameterType.SoftEnum,
12+
c.setSoftEnum('asdasdasd', ['az,', 'azzzzz'])
13+
)
14+
c.overload(['ssss', 'aaa'])
15+
c.setCallback(cb)
16+
c.setup()

Example/mc.pyi

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,24 @@ class Command:
288288
def setAlias(self, alias: str) -> bool:
289289
pass
290290

291+
def setSoftEnum(self, name, enums: list[str]) -> str:
292+
pass
293+
294+
def addSoftEnumValues(self, name, values: list[str]) -> bool:
295+
pass
296+
297+
def removeSoftEnumValues(self, name, values: list[str]) -> bool:
298+
pass
299+
300+
def getSoftEnumValues(self, name) -> list[str]:
301+
pass
302+
303+
def getSoftEnumNames(self) -> list[str]:
304+
pass
305+
291306
def mandatory2(
292307
self,
293-
name,
308+
name: str,
294309
type: ParameterType,
295310
description: str = "",
296311
identifier: str = "",
@@ -300,7 +315,7 @@ class Command:
300315

301316
def mandatory(
302317
self,
303-
name,
318+
name: str,
304319
type: ParameterType,
305320
description: str = "",
306321
option=CommandParameterOption.None_
@@ -326,21 +341,6 @@ class Command:
326341
) -> int:
327342
pass
328343

329-
def setSoftEnum(self, name, enums: list[str]) -> bool:
330-
pass
331-
332-
def addSoftEnumValues(self, name, values: list[str]) -> bool:
333-
pass
334-
335-
def removeSoftEnumValues(self, name, values: list[str]) -> bool:
336-
pass
337-
338-
def getSoftEnumValues(self, name) -> list[str]:
339-
pass
340-
341-
def getSoftEnumNames(self) -> list[str]:
342-
pass
343-
344344
def overload(self, value=None) -> bool:
345345
pass
346346

@@ -473,6 +473,9 @@ class NBT:
473473
def asDouble(self) -> float:
474474
pass
475475

476+
def asString(self) -> str:
477+
pass
478+
476479
def toBinary(self) -> bytes:
477480
pass
478481

@@ -954,6 +957,7 @@ def runCommandEx(cmd) -> tuple[str, bool]:
954957
def setListener(event, callback) -> bool:
955958
pass
956959

960+
957961
# callback: (player: Player, result: dict[str, CommandResult]) -> None
958962
def registerCommand(
959963
name, desc, callback, perm=CommandPermissionLevel.GameMasters

Example/pshop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
pshop = {}
1515

1616

17-
def str2json(data):
17+
def str2json(data: str):
1818
jsondata = json.loads(data)
1919
return jsondata
2020

ModuleDef.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ PYBIND11_EMBEDDED_MODULE(mc, mc_module) {
130130

131131
.def("setEnum", &CommandClass::setEnum)
132132
.def("setAlias", &CommandClass::setAlias)
133-
.def("mandatory2", py::overload_cast<const string&, DynamicCommand::ParameterType, string, string, CommandParameterOption>(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None)
134-
.def("mandatory", py::overload_cast<const string&, DynamicCommand::ParameterType, string, CommandParameterOption>(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "option"_a = None)
135-
.def("optional2", py::overload_cast<const string&, DynamicCommand::ParameterType, string, string, CommandParameterOption>(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None)
136-
.def("optional", py::overload_cast<const string&, DynamicCommand::ParameterType, string, CommandParameterOption>(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "option"_a = None)
137133
.def("setSoftEnum", &CommandClass::setSoftEnum)
138134
.def("addSoftEnumValues", &CommandClass::addSoftEnumValues)
139135
.def("removeSoftEnumValues", &CommandClass::removeSoftEnumValues)
140136
.def("getSoftEnumValues", &CommandClass::getSoftEnumValues)
141137
.def("getSoftEnumNames", &CommandClass::getSoftEnumNames)
138+
.def("mandatory2", py::overload_cast<const string&, DynamicCommand::ParameterType, string, string, CommandParameterOption>(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None)
139+
.def("mandatory", py::overload_cast<const string&, DynamicCommand::ParameterType, string, CommandParameterOption>(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "option"_a = None)
140+
.def("optional2", py::overload_cast<const string&, DynamicCommand::ParameterType, string, string, CommandParameterOption>(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None)
141+
.def("optional", py::overload_cast<const string&, DynamicCommand::ParameterType, string, CommandParameterOption>(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "option"_a = None)
142142
.def("overload", py::overload_cast<>(&CommandClass::addOverload))
143143
.def("overload", py::overload_cast<const vector<size_t>&>(&CommandClass::addOverload))
144144
.def("overload", py::overload_cast<vector<string>&&>(&CommandClass::addOverload))

SDK

Submodule SDK updated from 1c93926 to 16bc6a1

0 commit comments

Comments
 (0)