From 65521418802bce55e99673d41ae56483a52cfc65 Mon Sep 17 00:00:00 2001 From: Och Noe Date: Sun, 14 Jan 2024 02:44:49 +0100 Subject: disable itself if server setting disallows chat function access --- init.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/init.lua b/init.lua index cb53412..1893f77 100644 --- a/init.lua +++ b/init.lua @@ -178,6 +178,36 @@ end +local cr = minetest.get_csm_restrictions() +local limitationlist = { "load_client_mods", "chat_messages", "read_itemdefs", + "read_nodedefs", "lookup_nodes", "read_playerinfo" } + +local modfunction_limited = {} + +if not cr then + minetest.display_chat_message("cr == nil") + return +else + for _,r in ipairs(limitationlist) do + modfunction_limited[r] = true + if cr[r] then + modfunction_limited[r] = false + end + end +end + +local function show_restrictions() + for _,r in ipairs(limitationlist) do + minetest.display_chat_message(string.format("%-20s: %s",r, (modfunction_limited[r] and "allowed") or "forbidden")) + end +end + +show_restrictions() + +if not modfunction_limited[ "chat_messages" ] then + minetest.display_chat_message( "chat_messages".." are forbidden --> not loading") + return +end local register_on_message = core.register_on_sending_chat_message if core.register_on_sending_chat_messages then @@ -527,3 +557,18 @@ core.register_chatcommand("say", { return true end, }) + + + +minetest.display_chat_message( "[CSM colour_chat] loaded") + + + + + + + + + + + -- cgit v1.2.3