---
sidebarDepth: 1
---
# 权限
## GetPlayerAbilities
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家具体权限
- 参数
无
- 返回值
|
数据类型
| 说明 |
| :--- | :--- |
| 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
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
获取玩家权限类型信息
- 参数
无
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| int | 权限类型,Visitor为0,Member为1,Operator为2,Custom为3 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
operation = comp.GetPlayerOperation()
```
## SetAttackMobsAbility
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否攻击生物
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| canAttack | bool | 能否攻击生物 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetAttackMobsAbility(False)
```
## SetAttackPlayersAbility
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否攻击其他玩家
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| canAttack | bool | 能否攻击其他玩家 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetAttackPlayersAbility(False)
```
## SetBuildAbility
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否放置方块,该接口的设置会存档,且只影响生存模式
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| canBuild | bool | 能否放置方块 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetBuildAbility(False)
```
## SetMineAbility
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否摧毁方块,该接口的设置会存档,且只影响生存模式
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| canMine | bool | 能否摧毁方块 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetMineAbility(False)
```
## SetOpenContainersAbility
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否打开容器
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| canOpen | bool | 能否打开容器 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetOpenContainersAbility(False)
```
## SetOperateDoorsAndSwitchesAbility
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否与门和开关交互
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| canOperate | bool | 能否与门和开关交互 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetOperateDoorsAndSwitchesAbility(False)
```
## SetOperatorCommandAbility
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家是否具有操作员命令权限
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| canOperate | bool | 是否能发送操作员命令 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetOperatorCommandAbility(False)
```
## SetPermissionLevel
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家权限等级
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| level | int | 权限等级,0为访客、1为成员、2为操作员、3为自定义 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPermissionLevel(3)
```
## SetPlayerMute
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家是否禁言,该接口的设置不存档
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| isMute | bool | 是否禁言 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetPlayerMute(True)
```
## SetTeleportAbility
服务端
method in mod.server.component.playerCompServer.PlayerCompServer
- 描述
设置玩家能否使用TP指令
- 参数
| 参数名 | 数据类型
| 说明 |
| :--- | :--- | :--- |
| canTeleport | bool | 能否使用TP指令 |
- 返回值
| 数据类型
| 说明 |
| :--- | :--- |
| bool | 是否设置成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreatePlayer(playerId)
comp.SetTeleportAbility(False)
```