2012-04-01 11:37:41 +02:00
|
|
|
-- Minetest: builtin/privileges.lua
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Privileges
|
|
|
|
--
|
|
|
|
|
2014-04-28 03:02:48 +02:00
|
|
|
core.registered_privileges = {}
|
2012-04-01 11:37:41 +02:00
|
|
|
|
2014-04-28 03:02:48 +02:00
|
|
|
function core.register_privilege(name, param)
|
2012-04-01 11:37:41 +02:00
|
|
|
local function fill_defaults(def)
|
|
|
|
if def.give_to_singleplayer == nil then
|
|
|
|
def.give_to_singleplayer = true
|
|
|
|
end
|
|
|
|
if def.description == nil then
|
|
|
|
def.description = "(no description)"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local def = {}
|
|
|
|
if type(param) == "table" then
|
|
|
|
def = param
|
|
|
|
else
|
|
|
|
def = {description = param}
|
|
|
|
end
|
|
|
|
fill_defaults(def)
|
2014-04-28 03:02:48 +02:00
|
|
|
core.registered_privileges[name] = def
|
2012-04-01 11:37:41 +02:00
|
|
|
end
|
|
|
|
|
2014-04-28 03:02:48 +02:00
|
|
|
core.register_privilege("interact", "Can interact with things and modify the world")
|
2016-11-06 00:37:20 +01:00
|
|
|
core.register_privilege("shout", "Can speak in chat")
|
2014-04-28 03:02:48 +02:00
|
|
|
core.register_privilege("basic_privs", "Can modify 'shout' and 'interact' privileges")
|
2016-11-06 00:37:20 +01:00
|
|
|
core.register_privilege("privs", "Can modify privileges")
|
|
|
|
|
|
|
|
core.register_privilege("teleport", {
|
|
|
|
description = "Can use /teleport command",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("bring", {
|
|
|
|
description = "Can teleport other players",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("settime", {
|
|
|
|
description = "Can use /time",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("server", {
|
|
|
|
description = "Can do server maintenance stuff",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2016-05-30 14:40:32 +02:00
|
|
|
core.register_privilege("protection_bypass", {
|
|
|
|
description = "Can bypass node protection in the world",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2016-11-06 00:37:20 +01:00
|
|
|
core.register_privilege("ban", {
|
|
|
|
description = "Can ban and unban players",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("kick", {
|
|
|
|
description = "Can kick players",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("give", {
|
|
|
|
description = "Can use /give and /giveme",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("password", {
|
|
|
|
description = "Can use /setpassword and /clearpassword",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2014-04-28 03:02:48 +02:00
|
|
|
core.register_privilege("fly", {
|
2012-04-01 11:37:41 +02:00
|
|
|
description = "Can fly using the free_move mode",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2014-04-28 03:02:48 +02:00
|
|
|
core.register_privilege("fast", {
|
2012-04-01 11:37:41 +02:00
|
|
|
description = "Can walk fast using the fast_move mode",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2014-04-28 03:02:48 +02:00
|
|
|
core.register_privilege("noclip", {
|
2012-12-09 13:34:16 +01:00
|
|
|
description = "Can fly through walls",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2016-11-06 00:37:20 +01:00
|
|
|
core.register_privilege("rollback", {
|
|
|
|
description = "Can use the rollback functionality",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2016-11-04 03:14:32 +01:00
|
|
|
core.register_privilege("debug", {
|
|
|
|
description = "Allows enabling various debug options that may affect gameplay",
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2017-09-04 22:08:59 +02:00
|
|
|
|
|
|
|
core.register_can_bypass_userlimit(function(name, ip)
|
|
|
|
local privs = core.get_player_privs(name)
|
|
|
|
return privs["server"] or privs["ban"] or privs["privs"] or privs["password"]
|
|
|
|
end)
|