Files
netease-modsdk-wiki/docs/mcdocs/1-ModAPI/接口/玩家/权限.md
2025-03-18 14:46:12 +08:00

403 lines
8.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebarDepth: 1
---
# 权限
## GetPlayerAbilities
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家具体权限
- 参数
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| dict | 具体权限,详见备注 |
- 备注
- 具体权限说明
| 权限字段 | 数据类型 | 说明 |
| --------| ---- |------|
| build | bool | 放置方块 |
| mine | bool | 采集方块 |
| doorsandswitches | bool | 使用门和开关 |
| opencontainers | bool | 打开容器 |
| attackplayers | bool | 攻击玩家 |
| attackmobs | bool | 攻击生物 |
| op | bool | 操作员命令 |
| teleport | bool | 使用传送 |
- 返回值示例
```python
{'teleport': True, 'opencontainers': True, 'mine': True, 'build': True, 'op': True, 'attackmobs': True, 'doorsandswitches': True, 'attackplayers': True}
```
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
operation = comp.GetPlayerAbilities()
```
## GetPlayerOperation
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家权限类型信息
- 参数
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| int | 权限类型Visitor为0Member为1Operator为2Custom为3 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
operation = comp.GetPlayerOperation()
```
## SetAttackMobsAbility
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否攻击生物
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| canAttack | bool | 能否攻击生物 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetAttackMobsAbility(False)
```
## SetAttackPlayersAbility
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否攻击其他玩家
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| canAttack | bool | 能否攻击其他玩家 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetAttackPlayersAbility(False)
```
## SetBuildAbility
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否放置方块,该接口的设置会存档,且只影响生存模式
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| canBuild | bool | 能否放置方块 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetBuildAbility(False)
```
## SetMineAbility
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否摧毁方块,该接口的设置会存档,且只影响生存模式
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| canMine | bool | 能否摧毁方块 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetMineAbility(False)
```
## SetOpenContainersAbility
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否打开容器
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| canOpen | bool | 能否打开容器 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetOpenContainersAbility(False)
```
## SetOperateDoorsAndSwitchesAbility
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否与门和开关交互
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| canOperate | bool | 能否与门和开关交互 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetOperateDoorsAndSwitchesAbility(False)
```
## SetOperatorCommandAbility
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家是否具有操作员命令权限
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| canOperate | bool | 是否能发送操作员命令 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetOperatorCommandAbility(False)
```
## SetPermissionLevel
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家权限等级
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| level | int | 权限等级0为访客、1为成员、2为操作员、3为自定义 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPermissionLevel(3)
```
## SetPlayerMute
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家是否禁言,该接口的设置不存档
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| isMute | bool | 是否禁言 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPlayerMute(True)
```
## SetTeleportAbility
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否使用TP指令
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| canTeleport | bool | 能否使用TP指令 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetTeleportAbility(False)
```