From 01ac3f8d9fde2666434fa9988596d582ca90a7f3 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Fri, 3 Apr 2020 17:03:07 +0800 Subject: [PATCH] more precise permission control --- QuickBackupM.py | 18 ++++++++++++------ README.md | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/QuickBackupM.py b/QuickBackupM.py index 5778d85..f8d5b93 100644 --- a/QuickBackupM.py +++ b/QuickBackupM.py @@ -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' @@ -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 [] diff --git a/README.md b/README.md index 4dfd2f6..437c5aa 100644 --- a/README.md +++ b/README.md @@ -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` 以让所有人均可操作