diff --git a/mods/default/chat.lua b/mods/default/chat.lua new file mode 100644 index 0000000000..996973a412 --- /dev/null +++ b/mods/default/chat.lua @@ -0,0 +1,28 @@ +-- mods/default/chat.lua + +local function match_old(privs) + local ok = false + for k, v in pairs(privs) do + if k == "give" and v then + ok = true + elseif v then + return false + end + end + return ok +end + +-- Change /pulverize and /clearinv to not require give, like it used to be +-- before Luanti 5.15 +for _, cmd in ipairs({"pulverize", "clearinv"}) do + local def = core.registered_chatcommands[cmd] + if def then + if match_old(def.privs) then + core.override_chatcommand(cmd, { + privs = {interact=true}, + }) + else + minetest.log("info", "Privileges of command /" .. cmd .. " look modified, not overriding them.") + end + end +end diff --git a/mods/default/init.lua b/mods/default/init.lua index 649b5c00fd..e7c15097e9 100644 --- a/mods/default/init.lua +++ b/mods/default/init.lua @@ -75,6 +75,7 @@ dofile(default_path.."/item_entity.lua") dofile(default_path.."/craftitems.lua") dofile(default_path.."/crafting.lua") dofile(default_path.."/mapgen.lua") +dofile(default_path.."/chat.lua") dofile(default_path.."/aliases.lua") dofile(default_path.."/legacy.lua")