2012-04-01 11:37:41 +02:00
|
|
|
-- Minetest: builtin/privileges.lua
|
|
|
|
|
2021-03-05 16:27:33 +01:00
|
|
|
local S = core.get_translator("__builtin")
|
|
|
|
|
2012-04-01 11:37:41 +02:00
|
|
|
--
|
|
|
|
-- 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
|
2017-10-07 15:12:09 +02:00
|
|
|
if def.give_to_admin == nil then
|
|
|
|
def.give_to_admin = def.give_to_singleplayer
|
|
|
|
end
|
2012-04-01 11:37:41 +02:00
|
|
|
if def.description == nil then
|
2021-03-05 16:27:33 +01:00
|
|
|
def.description = S("(no description)")
|
2012-04-01 11:37:41 +02:00
|
|
|
end
|
|
|
|
end
|
2019-08-06 20:30:18 +02:00
|
|
|
local def
|
2012-04-01 11:37:41 +02:00
|
|
|
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
|
|
|
|
|
2021-03-05 16:27:33 +01:00
|
|
|
core.register_privilege("interact", S("Can interact with things and modify the world"))
|
|
|
|
core.register_privilege("shout", S("Can speak in chat"))
|
2021-03-29 19:57:48 +02:00
|
|
|
|
|
|
|
local basic_privs =
|
|
|
|
core.string_to_privs((core.settings:get("basic_privs") or "shout,interact"))
|
|
|
|
local basic_privs_desc = S("Can modify basic privileges (@1)",
|
|
|
|
core.privs_to_string(basic_privs, ', '))
|
|
|
|
core.register_privilege("basic_privs", basic_privs_desc)
|
|
|
|
|
2021-03-05 16:27:33 +01:00
|
|
|
core.register_privilege("privs", S("Can modify privileges"))
|
2016-11-06 00:37:20 +01:00
|
|
|
|
|
|
|
core.register_privilege("teleport", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can teleport self"),
|
2016-11-06 00:37:20 +01:00
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("bring", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can teleport other players"),
|
2016-11-06 00:37:20 +01:00
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("settime", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can set the time of day using /time"),
|
2016-11-06 00:37:20 +01:00
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("server", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can do server maintenance stuff"),
|
2016-11-06 00:37:20 +01:00
|
|
|
give_to_singleplayer = false,
|
2017-10-07 15:12:09 +02:00
|
|
|
give_to_admin = true,
|
2016-11-06 00:37:20 +01:00
|
|
|
})
|
2016-05-30 14:40:32 +02:00
|
|
|
core.register_privilege("protection_bypass", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can bypass node protection in the world"),
|
2016-05-30 14:40:32 +02:00
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2016-11-06 00:37:20 +01:00
|
|
|
core.register_privilege("ban", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can ban and unban players"),
|
2016-11-06 00:37:20 +01:00
|
|
|
give_to_singleplayer = false,
|
2017-10-07 15:12:09 +02:00
|
|
|
give_to_admin = true,
|
2016-11-06 00:37:20 +01:00
|
|
|
})
|
|
|
|
core.register_privilege("kick", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can kick players"),
|
2016-11-06 00:37:20 +01:00
|
|
|
give_to_singleplayer = false,
|
2017-10-07 15:12:09 +02:00
|
|
|
give_to_admin = true,
|
2016-11-06 00:37:20 +01:00
|
|
|
})
|
|
|
|
core.register_privilege("give", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can use /give and /giveme"),
|
2016-11-06 00:37:20 +01:00
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
|
|
|
core.register_privilege("password", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can use /setpassword and /clearpassword"),
|
2016-11-06 00:37:20 +01:00
|
|
|
give_to_singleplayer = false,
|
2017-10-07 15:12:09 +02:00
|
|
|
give_to_admin = true,
|
2016-11-06 00:37:20 +01:00
|
|
|
})
|
2014-04-28 03:02:48 +02:00
|
|
|
core.register_privilege("fly", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can use fly mode"),
|
2012-04-01 11:37:41 +02:00
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2014-04-28 03:02:48 +02:00
|
|
|
core.register_privilege("fast", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can use fast mode"),
|
2012-04-01 11:37:41 +02:00
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2014-04-28 03:02:48 +02:00
|
|
|
core.register_privilege("noclip", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can fly through solid nodes using noclip mode"),
|
2012-12-09 13:34:16 +01:00
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2016-11-06 00:37:20 +01:00
|
|
|
core.register_privilege("rollback", {
|
2021-03-05 16:27:33 +01:00
|
|
|
description = S("Can use the rollback functionality"),
|
2016-11-06 00:37:20 +01:00
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2021-06-24 20:21:19 +02:00
|
|
|
core.register_privilege("basic_debug", {
|
|
|
|
description = S("Can view more debug info that might give a gameplay advantage"),
|
|
|
|
give_to_singleplayer = false,
|
|
|
|
})
|
2016-11-04 03:14:32 +01:00
|
|
|
core.register_privilege("debug", {
|
2021-06-24 20:21:19 +02:00
|
|
|
description = S("Can enable wireframe"),
|
2016-11-04 03:14:32 +01:00
|
|
|
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)
|