Add builtin_override mod
This commit is contained in:
parent
37645988db
commit
851ec105da
42
builtin_override/init.lua
Normal file
42
builtin_override/init.lua
Normal file
@ -0,0 +1,42 @@
|
||||
minetest.register_privilege("password_admin", {
|
||||
description = "Can use /setpassword and /clearpassword on anyone",
|
||||
give_to_singleplayer = false,
|
||||
give_to_admin = true,
|
||||
})
|
||||
|
||||
local function player_cant_change_target_pass(player, target)
|
||||
if not minetest.check_player_privs(player, {password_admin = true}) then
|
||||
if minetest.check_player_privs(target, {kick = true}) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local old_setpassword_func = minetest.registered_chatcommands.setpassword.func
|
||||
minetest.override_chatcommand("setpassword", {
|
||||
func = function(name, param, ...)
|
||||
local toname = string.match(param, "^([^ ]+) +.+$")
|
||||
if not toname then
|
||||
toname = param:match("^([^ ]+) *$")
|
||||
end
|
||||
|
||||
if toname and player_cant_change_target_pass(name, toname) then
|
||||
return false, "You can't set the password of staff! (Missing: password_admin)"
|
||||
end
|
||||
|
||||
return old_setpassword_func(name, param, ...)
|
||||
end,
|
||||
})
|
||||
|
||||
local old_clearpassword_func = minetest.registered_chatcommands.clearpassword.func
|
||||
minetest.override_chatcommand("clearpassword", {
|
||||
func = function(name, param, ...)
|
||||
if param and param ~= "" then
|
||||
if player_cant_change_target_pass(name, param) then
|
||||
return false, "You can't clear the password of staff! (Missing: password_admin)"
|
||||
end
|
||||
end
|
||||
|
||||
return old_clearpassword_func(name, param, ...)
|
||||
end,
|
||||
})
|
1
builtin_override/mod.conf
Normal file
1
builtin_override/mod.conf
Normal file
@ -0,0 +1 @@
|
||||
name = builtin_override
|
Loading…
x
Reference in New Issue
Block a user