mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
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
This commit is contained in:
@@ -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, ', ')
|
||||
|
Reference in New Issue
Block a user