Merge pull request 'Fix interact behavior to prevent hackers from get interact back through shields' (#150) from NO11/MineClone5:shield_additions into master

Reviewed-on: MineClone5/MineClone5#150
This commit is contained in:
NO11 2022-01-31 17:09:48 +00:00
commit e48f089761
3 changed files with 26 additions and 9 deletions

View File

@ -29,7 +29,7 @@ local psdef= {
minpos = vector.new(-6,3,-6), minpos = vector.new(-6,3,-6),
maxpos = vector.new(6,15,6), maxpos = vector.new(6,15,6),
minvel = vector.new(-vel,-falling_speed,-vel), minvel = vector.new(-vel,-falling_speed,-vel),
maxvel = math.random(vel,-falling_speed+vel,vel), maxvel = vector.new(vel,-falling_speed+vel,vel),
minacc = vector.new(0,0,0), minacc = vector.new(0,0,0),
maxacc = vector.new(0,-0.4,0), maxacc = vector.new(0,-0.4,0),
minexptime = 0.5, minexptime = 0.5,
@ -46,7 +46,7 @@ local psdef_backsplash= {
minpos = vector.new(-3,-1,-3), minpos = vector.new(-3,-1,-3),
maxpos = vector.new(3,0,3), maxpos = vector.new(3,0,3),
minvel = vector.new(-vel,falling_speed*2,-vel), minvel = vector.new(-vel,falling_speed*2,-vel),
maxvel = math.random(vel,falling_speed*2+vel,vel), maxvel = vector.new(vel,falling_speed*2+vel,vel),
minacc = vector.new(0,0,0), minacc = vector.new(0,0,0),
maxacc = vector.new(0,0,0), maxacc = vector.new(0,0,0),
minexptime = 0.1, minexptime = 0.1,

View File

@ -183,10 +183,13 @@ local function set_interact(player, interact)
local player_name = player:get_player_name() local player_name = player:get_player_name()
local privs = minetest.get_player_privs(player_name) local privs = minetest.get_player_privs(player_name)
if privs.interact ~= interact then if privs.interact ~= interact then
local meta = player:get_meta()
if meta:get_int("ineract_revoked") ~= 1 then
privs.interact = interact privs.interact = interact
minetest.set_player_privs(player_name, privs) minetest.set_player_privs(player_name, privs)
end end
end end
end
local shield_hud = {} local shield_hud = {}

View File

@ -20,12 +20,26 @@ end)
for _, action in pairs({"grant", "revoke"}) do for _, action in pairs({"grant", "revoke"}) do
minetest["register_on_priv_" .. action](function(name, _, priv) minetest["register_on_priv_" .. action](function(name, _, priv)
if priv == "fly" then
local player = minetest.get_player_by_name(name) local player = minetest.get_player_by_name(name)
if player then if player then
local meta = player:get_meta() local meta = player:get_meta()
if priv == "fly" then
meta:set_int("fly_changed", 1) meta:set_int("fly_changed", 1)
end 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
end end
end) end)
end end