2021-05-29 14:12:33 +00:00
|
|
|
local S = minetest.get_translator(minetest.get_current_modname())
|
2019-03-07 20:14:30 +00:00
|
|
|
|
2017-12-12 23:30:23 +00:00
|
|
|
minetest.register_privilege("maphack", {
|
2019-03-07 20:14:30 +00:00
|
|
|
description = S("Can place and use advanced blocks like mob spawners, command blocks and barriers."),
|
2017-12-12 23:30:23 +00:00
|
|
|
})
|
2021-09-19 11:15:19 +00:00
|
|
|
|
2021-09-27 20:00:11 +00:00
|
|
|
minetest.register_on_joinplayer(function(player)
|
2021-09-19 11:18:09 +00:00
|
|
|
local name = player:get_player_name()
|
2021-09-27 20:00:11 +00:00
|
|
|
local meta = player:get_meta()
|
2022-03-27 16:08:43 +00:00
|
|
|
if meta:get_int("mcl_privs:fly_changed") == 1 then return end
|
2021-09-27 20:00:11 +00:00
|
|
|
|
2021-09-19 11:28:07 +00:00
|
|
|
local fly = nil
|
2021-09-19 11:15:19 +00:00
|
|
|
if minetest.is_creative_enabled(name) then
|
|
|
|
fly = true
|
|
|
|
end
|
2021-09-30 20:14:13 +00:00
|
|
|
local player_privs = minetest.get_player_privs(name)
|
|
|
|
player_privs.fly = fly
|
|
|
|
minetest.set_player_privs(name, player_privs)
|
2021-09-19 11:15:19 +00:00
|
|
|
end)
|
2021-09-27 20:00:11 +00:00
|
|
|
|
2021-09-30 20:14:13 +00:00
|
|
|
for _, action in pairs({"grant", "revoke"}) do
|
2021-09-27 20:00:11 +00:00
|
|
|
minetest["register_on_priv_" .. action](function(name, _, priv)
|
2022-03-15 14:58:27 +00:00
|
|
|
local player = minetest.get_player_by_name(name)
|
2022-03-27 16:08:43 +00:00
|
|
|
if not player then
|
|
|
|
return
|
|
|
|
end
|
2022-03-15 14:58:27 +00:00
|
|
|
|
2022-03-27 16:08:43 +00:00
|
|
|
local meta = player:get_meta()
|
|
|
|
|
|
|
|
if priv == "fly" then
|
|
|
|
meta:set_int("mcl_privs:fly_changed", 1)
|
|
|
|
end
|
2022-03-15 14:58:27 +00:00
|
|
|
|
2022-03-27 16:08:43 +00:00
|
|
|
--[[
|
|
|
|
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("mcl_privs:interact_revoked", 1)
|
|
|
|
else
|
|
|
|
meta:set_int("mcl_privs:interact_revoked", 0)
|
2022-03-15 14:58:27 +00:00
|
|
|
end
|
2021-09-27 20:00:11 +00:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|