forked from mtcontrib/name_restrictions
		
	Compare commits
	
		
			5 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2f4569266e | |||
| 
						 | 
					227445d5c7 | ||
| 
						 | 
					3160d7a624 | ||
| c58a4d5e49 | |||
| 97592b5eec | 
							
								
								
									
										38
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								init.lua
									
									
									
									
									
								
							@@ -7,22 +7,22 @@
 | 
				
			|||||||
-- For legitimate player names that are caught by the filters.
 | 
					-- For legitimate player names that are caught by the filters.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local exemptions = {}
 | 
					local exemptions = {}
 | 
				
			||||||
local temp = minetest.setting_get("name_restrictions.exemptions")
 | 
					local temp = minetest.settings:get("name_restrictions.exemptions")
 | 
				
			||||||
temp = temp and temp:split() or {}
 | 
					temp = temp and temp:split() or {}
 | 
				
			||||||
for _, allowed_name in pairs(temp) do
 | 
					for _, allowed_name in pairs(temp) do
 | 
				
			||||||
	exemptions[allowed_name] = true
 | 
						exemptions[allowed_name] = true
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
temp = nil
 | 
					temp = nil
 | 
				
			||||||
-- Exempt server owner
 | 
					-- Exempt server owner
 | 
				
			||||||
exemptions[minetest.setting_get("name")] = true
 | 
					exemptions[minetest.settings:get("name")] = true
 | 
				
			||||||
exemptions["singleplayer"] = true
 | 
					exemptions["singleplayer"] = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local disallowed_names
 | 
					local disallowed_names
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function load_forbidden_names()
 | 
					local function load_forbidden_names()
 | 
				
			||||||
	disallowed_names = {}
 | 
						disallowed_names = {}
 | 
				
			||||||
	local path = minetest.setting_get("name_restrictions.forbidden_names_list_path") or
 | 
						local path = minetest.settings:get("name_restrictions.forbidden_names_list_path") or
 | 
				
			||||||
		minetest.get_worldpath("name_restrictions") .. "/forbidden_names.txt"
 | 
							minetest.get_worldpath() .. "/forbidden_names.txt"
 | 
				
			||||||
	local file = io.open(path, 'r')
 | 
						local file = io.open(path, 'r')
 | 
				
			||||||
	if file then
 | 
						if file then
 | 
				
			||||||
		local count = 0
 | 
							local count = 0
 | 
				
			||||||
@@ -53,8 +53,8 @@ end
 | 
				
			|||||||
local disallowed
 | 
					local disallowed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function load_disallowed()
 | 
					local function load_disallowed()
 | 
				
			||||||
	local path = minetest.setting_get("name_restrictions.forbidden_name_patterns_list_path") or
 | 
						local path = minetest.settings:get("name_restrictions.forbidden_name_patterns_list_path") or
 | 
				
			||||||
		minetest.get_worldpath("name_restrictions") .. "/forbidden_names_patterns.txt"
 | 
							minetest.get_worldpath() .. "/forbidden_names_patterns.txt"
 | 
				
			||||||
	local file = io.open(path, 'r')
 | 
						local file = io.open(path, 'r')
 | 
				
			||||||
	if file then
 | 
						if file then
 | 
				
			||||||
		local content = file:read('*all')
 | 
							local content = file:read('*all')
 | 
				
			||||||
@@ -127,11 +127,12 @@ minetest.register_chatcommand("choosecase", {
 | 
				
			|||||||
	func = function(name, params)
 | 
						func = function(name, params)
 | 
				
			||||||
		local lname = params:lower()
 | 
							local lname = params:lower()
 | 
				
			||||||
		local worldpath = minetest.get_worldpath()
 | 
							local worldpath = minetest.get_worldpath()
 | 
				
			||||||
		local enumerate, e1, e2, e3 = minetest.get_auth_handler().enumerate_auths
 | 
							local auth_handler = minetest.get_auth_handler()
 | 
				
			||||||
		if enumerate then e1 = enumerate() else e1, e2, e3 = pairs(minetest.auth_table) end
 | 
							local enumerate, e1, e2, e3 = auth_handler.enumerate_auths
 | 
				
			||||||
 | 
							if enumerate then e1 = enumerate() else e1, e2, e3 = auth_handler.iterate() end
 | 
				
			||||||
		for iname, data in e1, e2, e3 do
 | 
							for iname, data in e1, e2, e3 do
 | 
				
			||||||
			if iname:lower() == lname and iname ~= params then
 | 
								if iname:lower() == lname and iname ~= params then
 | 
				
			||||||
				local delete = minetest.get_auth_handler().delete_auth
 | 
									local delete = auth_handler.delete_auth
 | 
				
			||||||
				if delete then
 | 
									if delete then
 | 
				
			||||||
					delete(iname)
 | 
										delete(iname)
 | 
				
			||||||
				else
 | 
									else
 | 
				
			||||||
@@ -189,8 +190,9 @@ all_chars = all_chars .. "]"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_on_prejoinplayer(function(name, ip)
 | 
					minetest.register_on_prejoinplayer(function(name, ip)
 | 
				
			||||||
	--MFF crabman (fix new player disallow old player with similaire name)
 | 
						--MFF crabman & sys4 (fix new player disallow old player with similaire name)
 | 
				
			||||||
	local exists = minetest.get_auth_handler().get_auth(name)
 | 
						local auth_handler = minetest.get_auth_handler()
 | 
				
			||||||
 | 
						local exists = auth_handler.get_auth(name)
 | 
				
			||||||
	if exists then return end
 | 
						if exists then return end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local lname = name:lower()
 | 
						local lname = name:lower()
 | 
				
			||||||
@@ -203,8 +205,8 @@ minetest.register_on_prejoinplayer(function(name, ip)
 | 
				
			|||||||
		return "Sorry. This name is forbidden."
 | 
							return "Sorry. This name is forbidden."
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local enumerate, e1, e2, e3 = minetest.get_auth_handler().enumerate_auths
 | 
						local enumerate, e1, e2, e3 = auth_handler.enumerate_auths
 | 
				
			||||||
	if enumerate then e1 = enumerate() else e1, e2, e3 = pairs(minetest.auth_table) end
 | 
						if enumerate then e1 = enumerate() else e1, e2, e3 = auth_handler.iterate() end
 | 
				
			||||||
	for iname, data in e1, e2, e3 do
 | 
						for iname, data in e1, e2, e3 do
 | 
				
			||||||
		if iname:lower() == lname and iname ~= name then
 | 
							if iname:lower() == lname and iname ~= name then
 | 
				
			||||||
			return "Sorry, someone else is already using this"
 | 
								return "Sorry, someone else is already using this"
 | 
				
			||||||
@@ -220,8 +222,8 @@ minetest.register_on_prejoinplayer(function(name, ip)
 | 
				
			|||||||
	local re = name:gsub(all_chars, char_map)
 | 
						local re = name:gsub(all_chars, char_map)
 | 
				
			||||||
	re = "^[_-]*" .. re .. "[_-]*$"
 | 
						re = "^[_-]*" .. re .. "[_-]*$"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local enumerate, e1, e2, e3 = minetest.get_auth_handler().enumerate_auths
 | 
						local enumerate, e1, e2, e3 = auth_handler.enumerate_auths
 | 
				
			||||||
	if enumerate then e1 = enumerate() else e1, e2, e3 = pairs(minetest.auth_table) end
 | 
						if enumerate then e1 = enumerate() else e1, e2, e3 = auth_handler.iterate() end
 | 
				
			||||||
	for authName, _ in e1, e2, e3 do
 | 
						for authName, _ in e1, e2, e3 do
 | 
				
			||||||
		if authName ~= name and authName:match(re) then
 | 
							if authName ~= name and authName:match(re) then
 | 
				
			||||||
			return "Your name is too similar to another player's name."
 | 
								return "Your name is too similar to another player's name."
 | 
				
			||||||
@@ -235,8 +237,8 @@ end)
 | 
				
			|||||||
-- Name length --
 | 
					-- Name length --
 | 
				
			||||||
-----------------
 | 
					-----------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local min_name_len = tonumber(minetest.setting_get("name_restrictions.minimum_name_length")) or 2
 | 
					local min_name_len = tonumber(minetest.settings:get("name_restrictions.minimum_name_length")) or 2
 | 
				
			||||||
local max_name_len = tonumber(minetest.setting_get("name_restrictions.maximum_name_length")) or 17
 | 
					local max_name_len = tonumber(minetest.settings:get("name_restrictions.maximum_name_length")) or 17
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_on_prejoinplayer(function(name, ip)
 | 
					minetest.register_on_prejoinplayer(function(name, ip)
 | 
				
			||||||
	if exemptions[name] then return end
 | 
						if exemptions[name] then return end
 | 
				
			||||||
@@ -307,7 +309,7 @@ end
 | 
				
			|||||||
--   0.5 = Strict checking.
 | 
					--   0.5 = Strict checking.
 | 
				
			||||||
--   1   = Normal checking.
 | 
					--   1   = Normal checking.
 | 
				
			||||||
--   2   = Relaxed checking.
 | 
					--   2   = Relaxed checking.
 | 
				
			||||||
local pronounceability = tonumber(minetest.setting_get("name_restrictions.pronounceability"))
 | 
					local pronounceability = tonumber(minetest.settings:get("name_restrictions.pronounceability"))
 | 
				
			||||||
if pronounceability then
 | 
					if pronounceability then
 | 
				
			||||||
	minetest.register_on_prejoinplayer(function(name, ip)
 | 
						minetest.register_on_prejoinplayer(function(name, ip)
 | 
				
			||||||
		if exemptions[name] then return end
 | 
							if exemptions[name] then return end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user