Skip to content

Commit

Permalink
more precise permission control
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Apr 3, 2020
1 parent 1b090bc commit 01ac3f8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
18 changes: 12 additions & 6 deletions QuickBackupM.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
WorldNames = [
'world',
]
MinimumPermissionLevel = 2 # helper
# 0:guest 1:user 2:helper 3:admin
MinimumPermissionLevel = {
'make': 1,
'back': 2,
'confirm': 1,
'abort': 1,
'share': 2,
'list': 0,
}
SharePath = '/home/shared'
OverwriteBackupFolder = 'overwrite'
ServerPath = './server'
Expand Down Expand Up @@ -339,11 +347,9 @@ def onServerInfo(server, info):

cmdLen = len(command)
# MCDR permission check
if hasattr(server, 'MCDR') and cmdLen >= 1 and command[0] in ['back', 'share']:
global MinimumPermissionLevel
if server.get_permission_level(info) >= MinimumPermissionLevel:
pass
else:
global MinimumPermissionLevel
if hasattr(server, 'MCDR') and cmdLen >= 1 and command[0] in MinimumPermissionLevel.keys():
if server.get_permission_level(info) < MinimumPermissionLevel[command[0]]:
print_message(server, info, '§c权限不足!§r')
return
# make [<comment>]
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ WorldNames = [

### MinimumPermissionLevel

默认值: `MinimumPermissionLevel = 2`
默认值:

```
MinimumPermissionLevel = {
'make': 1,
'back': 2,
'confirm': 1,
'abort': 1,
'share': 2,
'list': 0,
}
```

一个字典,代表使用不同类型指令需要权限等级。数值含义见[此处](https://github.com/Fallen-Breath/MCDReforged/blob/master/doc/readme_cn.md#权限)

一个整数,代表使用 `!!qb back` 以及 `!!qb share` 需要权限等级。数值含义见[此处](https://github.com/Fallen-Breath/MCDReforged/blob/master/doc/readme_cn.md#权限)
把所有数值设置成 `0` 以让所有人均可操作

0 comments on commit 01ac3f8

Please sign in to comment.