Corrige crash au démarrage.

* Les appels auth_handler ont été mis à jour pour être compatible
  Minetest 5.0.
This commit is contained in:
Sys Quatre 2019-04-08 00:21:17 +02:00
parent c9df43a1f6
commit 97592b5eec
1 changed files with 13 additions and 11 deletions

View File

@ -22,7 +22,7 @@ local disallowed_names
local function load_forbidden_names()
disallowed_names = {}
local path = minetest.setting_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')
if file then
local count = 0
@ -54,7 +54,7 @@ local disallowed
local function load_disallowed()
local path = minetest.setting_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')
if file then
local content = file:read('*all')
@ -127,11 +127,12 @@ minetest.register_chatcommand("choosecase", {
func = function(name, params)
local lname = params:lower()
local worldpath = minetest.get_worldpath()
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
local auth_handler = minetest.get_auth_handler()
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
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
delete(iname)
else
@ -189,8 +190,9 @@ 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)
--MFF crabman & sys4 (fix new player disallow old player with similaire name)
local auth_handler = minetest.get_auth_handler()
local exists = auth_handler.get_auth(name)
if exists then return end
local lname = name:lower()
@ -203,8 +205,8 @@ minetest.register_on_prejoinplayer(function(name, ip)
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
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
if iname:lower() == lname and iname ~= name then
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)
re = "^[_-]*" .. re .. "[_-]*$"
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
local enumerate, e1, e2, e3 = auth_handler.enumerate_auths
if enumerate then e1 = enumerate() else e1, e2, e3 = auth_handler.iterate() end
for authName, _ in e1, e2, e3 do
if authName ~= name and authName:match(re) then
return "Your name is too similar to another player's name."