aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rubenwardy@gmail.com>2016-04-09 16:07:45 +0100
committerparamat <mat.gregory@virginmedia.com>2016-04-28 07:19:07 +0100
commit17bfe2fe5b24aa7cf097bfe0a18dd3a66a0cee38 (patch)
tree08af2da28738cf88c9b9c2e0034f0b41ad473b36
parent30083d1e0070d0f86337a57ea36b6bba7fd52572 (diff)
downloadminetest-17bfe2fe5b24aa7cf097bfe0a18dd3a66a0cee38.tar.gz
minetest-17bfe2fe5b24aa7cf097bfe0a18dd3a66a0cee38.tar.bz2
minetest-17bfe2fe5b24aa7cf097bfe0a18dd3a66a0cee38.zip
Builtin: Add basic_privs setting
-rw-r--r--builtin/game/chatcommands.lua8
-rw-r--r--builtin/settingtypes.txt3
-rw-r--r--doc/lua_api.txt1
-rw-r--r--minetest.conf.example5
4 files changed, 14 insertions, 3 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua
index 4deff281d..7480446f2 100644
--- a/builtin/game/chatcommands.lua
+++ b/builtin/game/chatcommands.lua
@@ -181,8 +181,10 @@ core.register_chatcommand("grant", {
end
local privs = core.get_player_privs(grantname)
local privs_unknown = ""
+ local basic_privs =
+ core.string_to_privs(core.setting_get("basic_privs") or "interact,shout")
for priv, _ in pairs(grantprivs) do
- if priv ~= "interact" and priv ~= "shout" and
+ if not basic_privs[priv] and
not core.check_player_privs(name, {privs=true}) then
return false, "Your privileges are insufficient."
end
@@ -223,8 +225,10 @@ core.register_chatcommand("revoke", {
end
local revoke_privs = core.string_to_privs(revoke_priv_str)
local privs = core.get_player_privs(revoke_name)
+ local basic_privs =
+ core.string_to_privs(core.setting_get("basic_privs") or "interact,shout")
for priv, _ in pairs(revoke_privs) do
- if priv ~= "interact" and priv ~= "shout" and
+ if not basic_privs[priv] and
not core.check_player_privs(name, {privs=true}) then
return false, "Your privileges are insufficient."
end
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index ca331ff4e..0a9519610 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -691,6 +691,9 @@ default_password (Default password) string
# See /privs in game for a full list on your server and mod configuration.
default_privs (Default privileges) string interact, shout
+# Privileges that players with basic_privs can grant
+basic_privs (Basic Privileges) string interact, shout
+
# Whether players are shown to clients without any range limit.
# Deprecated, use the setting player_transfer_distance instead.
unlimited_player_transfer_distance (Unlimited player transfer distance) bool true
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 47624496b..4b5f969d3 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1924,6 +1924,7 @@ Call these functions only at load time!
* `minetest.register_privilege(name, definition)`
* `definition`: `"description text"`
* `definition`: `{ description = "description text", give_to_singleplayer = boolean, -- default: true }`
+ * To allow players with basic_privs to grant, see basic_privs minetest.conf setting.
* `minetest.register_authentication_handler(handler)`
* See `minetest.builtin_auth_handler` in `builtin.lua` for reference
diff --git a/minetest.conf.example b/minetest.conf.example
index e913140ae..6f0eb7869 100644
--- a/minetest.conf.example
+++ b/minetest.conf.example
@@ -826,6 +826,10 @@
# type: string
# default_privs = interact, shout
+# Privileges that players with basic_privs can grant
+# type: string
+# basic_privs = interact, shout
+
# Whether players are shown to clients without any range limit.
# Deprecated, use the setting player_transfer_distance instead.
# type: bool
@@ -1513,4 +1517,3 @@
# type: string
# modstore_details_url = https://forum.minetest.net/mmdb/mod/*/
-