summaryrefslogtreecommitdiff
path: root/builtin/game/chatcommands.lua
diff options
context:
space:
mode:
authorrubenwardy <rubenwardy@gmail.com>2017-08-26 07:17:05 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-08-26 08:17:05 +0200
commit096ea031de5bdb3e51d2ceb12e6b7e2f2053081e (patch)
tree299fa6f103e70c091cbd73c221046ec2fc302d35 /builtin/game/chatcommands.lua
parentad9677a14fb8ad1b4048e83a779e5ad36a99f2d0 (diff)
downloadminetest-096ea031de5bdb3e51d2ceb12e6b7e2f2053081e.tar.gz
minetest-096ea031de5bdb3e51d2ceb12e6b7e2f2053081e.tar.bz2
minetest-096ea031de5bdb3e51d2ceb12e6b7e2f2053081e.zip
Add on_grant and on_revoke callbacks (#4713)
* Add register_on_priv_grant/revoke, and on_grant/revoke to privs. Call from /grant and /revoke * Call on_grant and on_revoke callbacks from set_privs
Diffstat (limited to 'builtin/game/chatcommands.lua')
-rw-r--r--builtin/game/chatcommands.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua
index 183e06a03..05b814d6f 100644
--- a/builtin/game/chatcommands.lua
+++ b/builtin/game/chatcommands.lua
@@ -132,6 +132,9 @@ local function handle_grant_command(caller, grantname, grantprivstr)
if privs_unknown ~= "" then
return false, privs_unknown
end
+ for priv, _ in pairs(grantprivs) do
+ core.run_priv_callbacks(grantname, priv, caller, "grant")
+ end
core.set_player_privs(grantname, privs)
core.log("action", caller..' granted ('..core.privs_to_string(grantprivs, ', ')..') privileges to '..grantname)
if grantname ~= caller then
@@ -193,12 +196,18 @@ core.register_chatcommand("revoke", {
end
end
if revoke_priv_str == "all" then
+ revoke_privs = privs
privs = {}
else
for priv, _ in pairs(revoke_privs) do
privs[priv] = nil
end
end
+
+ for priv, _ in pairs(revoke_privs) do
+ core.run_priv_callbacks(revoke_name, priv, name, "revoke")
+ end
+
core.set_player_privs(revoke_name, privs)
core.log("action", name..' revoked ('
..core.privs_to_string(revoke_privs, ', ')