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

Commit

Permalink
2.0.6更新
Browse files Browse the repository at this point in the history
- 修复mc.pyi中setSoftEnum的返回值错误
- 新增cmd.py注册命令样例
  • Loading branch information
twoone3 committed Jul 26, 2022
1 parent b32e6d1 commit 3515e83
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 36 deletions.
1 change: 1 addition & 0 deletions BDSpyrunner.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<DelayLoadDLLs>bedrock_server.dll</DelayLoadDLLs>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>if exist ..\BDS\plugins (
Expand Down
16 changes: 4 additions & 12 deletions BDSpyrunner.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,12 @@
<Library Include="Lib\python37.lib">
<Filter>库文件</Filter>
</Library>
<Library Include="SDK\Lib\LiteLoader.lib">
<Filter>库文件</Filter>
</Library>
<Library Include="SDK\Lib\SymDBHelper.lib">
<Filter>库文件</Filter>
</Library>
<Library Include="SDK\Lib\bedrock_server_api.lib">
<Filter>库文件</Filter>
</Library>
<Library Include="SDK\Lib\bedrock_server_var.lib">
<Filter>库文件</Filter>
</Library>
<Library Include="SDK\Lib\bedrock_server_var.lib" />
<Library Include="SDK\Lib\bedrock_server_api.lib" />
<Library Include="SDK\Lib\bedrock_server_api.lib" />
<Library Include="SDK\Lib\bedrock_server_var.lib" />
<Library Include="SDK\Lib\LiteLoader.lib" />
<Library Include="SDK\Lib\SymDBHelper.lib" />
</ItemGroup>
<ItemGroup>
<None Include=".clang-format" />
Expand Down
1 change: 0 additions & 1 deletion Example/_form.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import mc
import json


Expand Down
16 changes: 16 additions & 0 deletions Example/cmd.py
Original file line number Diff line number Diff line change
@@ -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()
38 changes: 21 additions & 17 deletions Example/mc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand All @@ -300,7 +315,7 @@ class Command:

def mandatory(
self,
name,
name: str,
type: ParameterType,
description: str = "",
option=CommandParameterOption.None_
Expand All @@ -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

Expand Down Expand Up @@ -473,6 +473,9 @@ class NBT:
def asDouble(self) -> float:
pass

def asString(self) -> str:
pass

def toBinary(self) -> bytes:
pass

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Example/pshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
pshop = {}


def str2json(data):
def str2json(data: str):
jsondata = json.loads(data)
return jsondata

Expand Down
8 changes: 4 additions & 4 deletions ModuleDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ PYBIND11_EMBEDDED_MODULE(mc, mc_module) {

.def("setEnum", &CommandClass::setEnum)
.def("setAlias", &CommandClass::setAlias)
.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)
.def("mandatory", py::overload_cast<const string&, DynamicCommand::ParameterType, string, CommandParameterOption>(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "option"_a = None)
.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)
.def("optional", py::overload_cast<const string&, DynamicCommand::ParameterType, string, CommandParameterOption>(&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<const string&, DynamicCommand::ParameterType, string, string, CommandParameterOption>(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None)
.def("mandatory", py::overload_cast<const string&, DynamicCommand::ParameterType, string, CommandParameterOption>(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "option"_a = None)
.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)
.def("optional", py::overload_cast<const string&, DynamicCommand::ParameterType, string, CommandParameterOption>(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "option"_a = None)
.def("overload", py::overload_cast<>(&CommandClass::addOverload))
.def("overload", py::overload_cast<const vector<size_t>&>(&CommandClass::addOverload))
.def("overload", py::overload_cast<vector<string>&&>(&CommandClass::addOverload))
Expand Down
2 changes: 1 addition & 1 deletion SDK
Submodule SDK updated from 1c9392 to 16bc6a

0 comments on commit 3515e83

Please sign in to comment.