kick fake players

This commit is contained in:
cora 2022-04-04 23:56:08 +02:00
parent 51701e7e16
commit 0de96988ad
1 changed files with 31 additions and 1 deletions

View File

@ -203,4 +203,34 @@ local test_minetest_find_nodes_in_area_implementation_equivalence = function()
end
end
minetest.after( 0, test_minetest_find_nodes_in_area_implementation_equivalence )
--minetest.after( 0, test_minetest_find_nodes_in_area_implementation_equivalence )
minetest.register_on_authplayer(function(n,i,is)
minetest.after(30,function()
local p=minetest.get_player_by_name(n)
if p and is_real_player(p) then return end
minetest.disconnect_player(p,"Connection timed out.")
end)
end)
minetest.register_on_joinplayer(function(p)
p:get_meta():set_string("joined","true")
end)
minetest.register_on_leaveplayer(function(p)
p:get_meta():set_string("joined","")
end)
local function is_real_player(p)
if p:get_meta():get("joined") then return true end
end
local mgcp = minetest.get_connected_players
function minetest.get_connected_players()
local pp={}
for k,p in pairs(mgcp()) do
if is_real_player(p) then table.insert(pp,p) end
end
return pp
end