Skip to content

Commit 17bfe2f

Browse files
rubenwardyparamat
authored andcommittedApr 28, 2016
Builtin: Add basic_privs setting
1 parent 30083d1 commit 17bfe2f

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed
 

‎builtin/game/chatcommands.lua

+6-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,10 @@ core.register_chatcommand("grant", {
181181
end
182182
local privs = core.get_player_privs(grantname)
183183
local privs_unknown = ""
184+
local basic_privs =
185+
core.string_to_privs(core.setting_get("basic_privs") or "interact,shout")
184186
for priv, _ in pairs(grantprivs) do
185-
if priv ~= "interact" and priv ~= "shout" and
187+
if not basic_privs[priv] and
186188
not core.check_player_privs(name, {privs=true}) then
187189
return false, "Your privileges are insufficient."
188190
end
@@ -223,8 +225,10 @@ core.register_chatcommand("revoke", {
223225
end
224226
local revoke_privs = core.string_to_privs(revoke_priv_str)
225227
local privs = core.get_player_privs(revoke_name)
228+
local basic_privs =
229+
core.string_to_privs(core.setting_get("basic_privs") or "interact,shout")
226230
for priv, _ in pairs(revoke_privs) do
227-
if priv ~= "interact" and priv ~= "shout" and
231+
if not basic_privs[priv] and
228232
not core.check_player_privs(name, {privs=true}) then
229233
return false, "Your privileges are insufficient."
230234
end

‎builtin/settingtypes.txt

+3
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,9 @@ default_password (Default password) string
691691
# See /privs in game for a full list on your server and mod configuration.
692692
default_privs (Default privileges) string interact, shout
693693

694+
# Privileges that players with basic_privs can grant
695+
basic_privs (Basic Privileges) string interact, shout
696+
694697
# Whether players are shown to clients without any range limit.
695698
# Deprecated, use the setting player_transfer_distance instead.
696699
unlimited_player_transfer_distance (Unlimited player transfer distance) bool true

‎doc/lua_api.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,7 @@ Call these functions only at load time!
19241924
* `minetest.register_privilege(name, definition)`
19251925
* `definition`: `"description text"`
19261926
* `definition`: `{ description = "description text", give_to_singleplayer = boolean, -- default: true }`
1927+
* To allow players with basic_privs to grant, see basic_privs minetest.conf setting.
19271928
* `minetest.register_authentication_handler(handler)`
19281929
* See `minetest.builtin_auth_handler` in `builtin.lua` for reference
19291930

‎minetest.conf.example

+4-1
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,10 @@
826826
# type: string
827827
# default_privs = interact, shout
828828

829+
# Privileges that players with basic_privs can grant
830+
# type: string
831+
# basic_privs = interact, shout
832+
829833
# Whether players are shown to clients without any range limit.
830834
# Deprecated, use the setting player_transfer_distance instead.
831835
# type: bool
@@ -1513,4 +1517,3 @@
15131517

15141518
# type: string
15151519
# modstore_details_url = https://forum.minetest.net/mmdb/mod/*/
1516-

0 commit comments

Comments
 (0)
Please sign in to comment.