From 19167a0ff194ae6c256b2bd1de09300b976faeba Mon Sep 17 00:00:00 2001 From: crabman77 Date: Mon, 19 Dec 2016 00:19:09 +0100 Subject: [PATCH] fix issue https://github.com/MinetestForFun/server-minetestforfun-skyblock/issues/193 many prejoin functions is bad, now 1 prejoin for all test --- init.lua | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/init.lua b/init.lua index 22138e0..c4d746e 100644 --- a/init.lua +++ b/init.lua @@ -90,17 +90,6 @@ do end end -minetest.register_on_prejoinplayer(function(name, ip) - local lname = name:lower() - for re, reason in pairs(disallowed) do - if lname:find(re) then - return reason - end - end - if disallowed_names[lname] then - return "Sorry. This name is forbidden." - end -end) -------------------------------------- -- Simple matching config reloading -- @@ -130,20 +119,6 @@ minetest.register_chatcommand("forbidden_names_reload", { -- Case-insensitivity -- ------------------------ -minetest.register_on_prejoinplayer(function(name, ip) - local lname = name:lower() - local enumerate, e1, e2, e3 = minetest.get_auth_handler().enumerate_auths - if enumerate then e1 = enumerate() else e1, e2, e3 = pairs(minetest.auth_table) end - for iname, data in e1, e2, e3 do - if iname:lower() == lname and iname ~= name then - return "Sorry, someone else is already using this" - .." name. Please pick another name." - .." Another possibility is that you used the" - .." wrong case for your name." - end - end -end) - -- Compatability, for old servers with conflicting players minetest.register_chatcommand("choosecase", { description = "Choose the casing that a player name should have", @@ -214,6 +189,31 @@ all_chars = all_chars .. "]" minetest.register_on_prejoinplayer(function(name, ip) + --MFF crabman (fix new player disallow old player with similaire name) + local exists = minetest.get_auth_handler().get_auth(name) + if exists then return end + + local lname = name:lower() + for re, reason in pairs(disallowed) do + if lname:find(re) then + return reason + end + end + if disallowed_names[lname] then + return "Sorry. This name is forbidden." + end + + local enumerate, e1, e2, e3 = minetest.get_auth_handler().enumerate_auths + if enumerate then e1 = enumerate() else e1, e2, e3 = pairs(minetest.auth_table) end + for iname, data in e1, e2, e3 do + if iname:lower() == lname and iname ~= name then + return "Sorry, someone else is already using this" + .." name. Please pick another name." + .." Another possibility is that you used the" + .." wrong case for your name." + end + end + if exemptions[name] then return end -- Generate a regular expression to match all similar names