1
0
Fork 0

Fix mistake when calling on_priv_grant/revoke, and document them (#6341)

mutilcraft-mt53
rubenwardy 2017-08-29 06:57:56 +01:00 committed by Loïc Blot
parent 2bd1a31239
commit 72c09f524b
2 changed files with 12 additions and 3 deletions

View File

@ -437,9 +437,9 @@ end
function core.run_priv_callbacks(name, priv, caller, method) function core.run_priv_callbacks(name, priv, caller, method)
if not core.registered_privileges[priv]["on_" .. method] or if not core.registered_privileges[priv]["on_" .. method] or
core.registered_privileges[priv]["on_" .. method](name, caller) then not core.registered_privileges[priv]["on_" .. method](name, caller) then
for _, func in ipairs(core["registered_on_priv_" .. method]) do for _, func in ipairs(core["registered_on_priv_" .. method]) do
if not func(name, caller) then if not func(name, caller, priv) then
break break
end end
end end

View File

@ -2447,6 +2447,14 @@ Call these functions only at load time!
* `minetest.register_on_item_eat(func(hp_change, replace_with_item, itemstack, user, pointed_thing))` * `minetest.register_on_item_eat(func(hp_change, replace_with_item, itemstack, user, pointed_thing))`
* Called when an item is eaten, by `minetest.item_eat` * Called when an item is eaten, by `minetest.item_eat`
* Return `true` or `itemstack` to cancel the default item eat response (i.e.: hp increase) * Return `true` or `itemstack` to cancel the default item eat response (i.e.: hp increase)
* `minetest.register_on_priv_grant(function(name, granter, priv))`
* Called when `granter` grants the priv `priv` to `name`.
* Note that the callback will be called twice if it's done by a player, once with granter being the player name,
and again with granter being nil.
* `minetest.register_on_priv_revoke(function(name, revoker, priv))`
* Called when `revoker` revokes the priv `priv` from `name`.
* Note that the callback will be called twice if it's done by a player, once with revoker being the player name,
and again with revoker being nil.
### Other registration functions ### Other registration functions
* `minetest.register_chatcommand(cmd, chatcommand definition)` * `minetest.register_chatcommand(cmd, chatcommand definition)`
@ -2466,6 +2474,7 @@ Call these functions only at load time!
`revoker_name` will be nil if the priv was revoked by a mod `revoker_name` will be nil if the priv was revoked by a mod
* Note that the above two callbacks will be called twice if a player is responsible - * Note that the above two callbacks will be called twice if a player is responsible -
once with the player name, and then with a nil player name. once with the player name, and then with a nil player name.
* Return true in the above callbacks to stop register_on_priv_grant or revoke being called.
* `minetest.register_authentication_handler(handler)` * `minetest.register_authentication_handler(handler)`
* See `minetest.builtin_auth_handler` in `builtin.lua` for reference * See `minetest.builtin_auth_handler` in `builtin.lua` for reference