指令
GetCommandPermissionLevel
服务端开发补充
服务端
method in mod.server.component.commandCompServer.CommandCompServer
- 描述
返回设定使用/op命令时OP的权限等级(对应server.properties中的op-permission-level配置)
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 权限等级:1-OP可以绕过重生点保护;2-OP可以使用所有单人游戏作弊命令;3-OP可以使用大多数多人游戏中独有的命令;4-OP可以使用所有命令 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateCommand(levelId)
opLevel = comp.GetCommandPermissionLevel()
print "GetCommandPermissionLevel oplevel={}".format(opLevel)GetDefaultPlayerPermissionLevel
服务端开发补充
读取新加入玩家默认获得的权限身份。
服务端
method in mod.server.component.commandCompServer.CommandCompServer
- 描述
返回新玩家加入时的权限身份(对应server.properties中的default-player-permission-level配置)
- 参数
无
- 返回值
| 数据类型 | 说明 |
|---|---|
| int | 权限身份:0-Visitor;1-Member;2-Operator;3-自定义 |
- 示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateCommand(levelId)
opLevel = comp.GetDefaultPlayerPermissionLevel()
print "GetDefaultPlayerPermissionLevel oplevel={}".format(opLevel)SetCommand
服务端开发补充
能力:动作栏 · 玩家
执行原生命令:屏幕中央标题用 title/titleraw 的 title、subtitle、times、clear、reset;动作栏用 actionbar;结构化聊天用 tellraw;记分板创建、显示与分数写入用 scoreboard。普通定向聊天可直接使用 NotifyOneMessage。
- 只作用于一个玩家时明确传入该玩家 entityId 并使用 @s;省略执行者会随机选择玩家。@a 表示全部玩家,执行者和接收者是两个概念。
- 标题 times 的时间单位为游戏 tick;先设置显示时间与副标题,再显示主标题。Tip/Popup 的位置与样式不等同于屏幕中央标题或原生 actionbar。
- JSON 文本使用序列化生成 rawtext,目标选择器和命令结构单独确定;不能直接套用 Java 版聊天组件格式。
- title、titleraw、scoreboard 的权限/作弊条件需按目标包体核验;SetCommand 返回的是执行结果,不是 Bukkit 的标题或记分板对象。
关联接口:NotifyOneMessage (server) · GetAllPlayerScoreboardObjects (server) · GetAllScoreboardObjects (server)
服务端
method in mod.server.component.commandCompServer.CommandCompServer
- 描述
使用游戏内指令
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| cmdStr | str | 指令 |
| entityId | str | 实体Id:可选,如果不设置,则随机选择玩家 |
| showOutput | bool | 是否输出到聊天窗口:可选,默认False,如果为True的话,指令正确时,才会和聊天框输入原生指令一样输出返回信息。只有当该参数为True的时候会触发OnCommandOutputServerEvent与OnCommandOutputClientEvent |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 命令是否执行成功 |
备注
entityId 为非玩家时,即使showOutput为true,也不会输出到聊天窗口,且OnCommandOutputClientEvent 事件不会被触发
极限模式下 需要开启作弊的指令无法调用
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateCommand(levelId)
comp.SetCommand("/tp @p 100 5 100")#传送指令SetCommandPermissionLevel
服务端开发补充
设置授予管理员身份时使用的指令权限等级。
服务端
method in mod.server.component.commandCompServer.CommandCompServer
- 描述
设置当玩家使用/op命令时OP的权限等级(对应server.properties中的op-permission-level配置)
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| opLevel | int | 权限等级:1-OP可以绕过重生点保护;2-OP可以使用所有单人游戏作弊命令;3-OP可以使用大多数多人游戏中独有的命令;4-OP可以使用所有命令 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 命令是否执行成功 |
备注
此API不会修改已经获取了op的玩家的权限等级,仅影响调用API之后才获取op的玩家,建议在游戏初始化时调用此API
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateCommand(levelId)
opLevel = 4
suc = comp.SetCommandPermissionLevel(opLevel)
print "SetCommandPermissionLevel to {} suc={}".format(opLevel, suc)SetDefaultPlayerPermissionLevel
服务端开发补充
设置新加入玩家默认获得的权限身份。
服务端
method in mod.server.component.commandCompServer.CommandCompServer
- 描述
设置新玩家加入时的权限身份(对应server.properties中的default-player-permission-level配置)
- 参数
| 参数名 | 数据类型 | 说明 |
|---|---|---|
| opLevel | int | 权限身份:0-Visitor;1-Member;2-Operator;3-自定义 |
- 返回值
| 数据类型 | 说明 |
|---|---|
| bool | 命令是否执行成功 |
备注
此API不会修改已经加入过游戏的玩家的权限身份,仅影响调用API之后才新加入的玩家,建议在游戏初始化时调用此API
示例
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateCommand(levelId)
opLevel = 1
suc = comp.SetDefaultPlayerPermissionLevel(opLevel)
print "SetDefaultPlayerPermissionLevel to {} suc={}".format(opLevel, suc)