diff --git a/mods/PLAYER/mcl_anticheat/init.lua b/mods/PLAYER/mcl_anticheat/init.lua index 2e3f427a6..cadad5c92 100644 --- a/mods/PLAYER/mcl_anticheat/init.lua +++ b/mods/PLAYER/mcl_anticheat/init.lua @@ -1,3 +1,6 @@ +local modpath = minetest.get_modpath(minetest.get_current_modname()) +dofile(modpath .. "/ratelimit.lua") + local enable_anticheat = true local kick_cheaters = false local kick_threshold = 10 diff --git a/mods/PLAYER/mcl_anticheat/ratelimit.lua b/mods/PLAYER/mcl_anticheat/ratelimit.lua new file mode 100644 index 000000000..4e4f5bd2d --- /dev/null +++ b/mods/PLAYER/mcl_anticheat/ratelimit.lua @@ -0,0 +1,21 @@ +-- by LoneWolfHT +-- https://github.com/minetest/minetest/issues/12220#issuecomment-1108789409 + +local ratelimit = {} +local after = minetest.after +local LIMIT = 2 + +local function remove_entry(ip) + ratelimit[ip] = nil +end + +minetest.register_on_mods_loaded(function() + table.insert(core.registered_on_prejoinplayers, 1, function(player, ip) + if ratelimit[ip] then + return "You are joining too fast, please try again" + else + ratelimit[ip] = true + after(LIMIT, remove_entry, ip) + end + end) +end)