1
0
Fork 0
MineClone2/mods/MISC/mcl_privs/init.lua

45 lines
1.2 KiB
Lua
Raw Normal View History

local S = minetest.get_translator(minetest.get_current_modname())
minetest.register_privilege("maphack", {
description = S("Can place and use advanced blocks like mob spawners, command blocks and barriers."),
})
2021-09-19 13:15:19 +02:00
2021-09-27 22:00:11 +02:00
minetest.register_on_joinplayer(function(player)
2021-09-19 13:18:09 +02:00
local name = player:get_player_name()
2021-09-27 22:00:11 +02:00
local meta = player:get_meta()
if meta:get_int("fly_changed") == 1 then return end
2021-09-19 13:28:07 +02:00
local fly = nil
2021-09-19 13:15:19 +02:00
if minetest.is_creative_enabled(name) then
fly = true
end
local player_privs = minetest.get_player_privs(name)
player_privs.fly = fly
minetest.set_player_privs(name, player_privs)
2021-09-19 13:15:19 +02:00
end)
2021-09-27 22:00:11 +02:00
for _, action in pairs({"grant", "revoke"}) do
2021-09-27 22:00:11 +02:00
minetest["register_on_priv_" .. action](function(name, _, priv)
2022-03-15 15:58:27 +01:00
local player = minetest.get_player_by_name(name)
if player then
2021-09-27 22:00:11 +02:00
local meta = player:get_meta()
2022-03-15 15:58:27 +01:00
if priv == "fly" then
meta:set_int("fly_changed", 1)
end
--[[
so e.g. hackers who have been revoked of the interact privilege
will not automatically get the interact privilege through the mcl shields code back
]]
if priv == "interact" then
if action == "revoke" then
meta:set_int("ineract_revoked", 1)
else
meta:set_int("ineract_revoked", 0)
end
end
2021-09-27 22:00:11 +02:00
end
end)
end