mirror of
https://github.com/minetest/minetest.git
synced 2024-12-29 09:27:30 +01:00
f627ef39e0
This privilege allows map protection bypassing for server operators and world moderators. Initially I had thought that bypassing protection mods would have been something that could entirely be done inside mods and minetest_game, but the concept of protection is defined in core, in the code of core.is_protected(). I don't feel that it would be logical to introduce a protection concept in core, but not some way around that for server operators to maintain map parts that need fixing, de-griefing or cleanup. Others had noticed the same problems, and proposed a patch to minetest_game. That patch is fine by itself, but it fails to add protection bypass functionality for digging normal nodes and placing nodes. So, instead, we indroduce the new priv "protection_bypass" in core, and modify 'on_place_node' and 'node_dig' to allow bypassing node protections if the player holds this priv. This priv was tested with protector redo by tenplus1. A followup patch to Minetest Game will include allowing special checks for doors, trapdoors, chests in Minetest Game. Protection mods will likely want to mimic the changes in their relevant code sections.
55 lines
1.8 KiB
Lua
55 lines
1.8 KiB
Lua
-- Minetest: builtin/privileges.lua
|
|
|
|
--
|
|
-- Privileges
|
|
--
|
|
|
|
core.registered_privileges = {}
|
|
|
|
function core.register_privilege(name, param)
|
|
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)
|
|
core.registered_privileges[name] = def
|
|
end
|
|
|
|
core.register_privilege("interact", "Can interact with things and modify the world")
|
|
core.register_privilege("teleport", "Can use /teleport command")
|
|
core.register_privilege("bring", "Can teleport other players")
|
|
core.register_privilege("settime", "Can use /time")
|
|
core.register_privilege("privs", "Can modify privileges")
|
|
core.register_privilege("basic_privs", "Can modify 'shout' and 'interact' privileges")
|
|
core.register_privilege("server", "Can do server maintenance stuff")
|
|
core.register_privilege("protection_bypass", "Can bypass node protection in the world")
|
|
core.register_privilege("shout", "Can speak in chat")
|
|
core.register_privilege("ban", "Can ban and unban players")
|
|
core.register_privilege("kick", "Can kick players")
|
|
core.register_privilege("give", "Can use /give and /giveme")
|
|
core.register_privilege("password", "Can use /setpassword and /clearpassword")
|
|
core.register_privilege("fly", {
|
|
description = "Can fly using the free_move mode",
|
|
give_to_singleplayer = false,
|
|
})
|
|
core.register_privilege("fast", {
|
|
description = "Can walk fast using the fast_move mode",
|
|
give_to_singleplayer = false,
|
|
})
|
|
core.register_privilege("noclip", {
|
|
description = "Can fly through walls",
|
|
give_to_singleplayer = false,
|
|
})
|
|
core.register_privilege("rollback", "Can use the rollback functionality")
|
|
|