forked from minetest-mods/xban2
Add .luacheckrc
and fix warnings.
This commit is contained in:
parent
97fb251ad9
commit
89303b4a01
7
.luacheckrc
Normal file
7
.luacheckrc
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
unused_args = false
|
||||||
|
allow_defined_top = true
|
||||||
|
|
||||||
|
read_globals = {
|
||||||
|
"minetest",
|
||||||
|
}
|
@ -11,13 +11,13 @@ minetest.register_chatcommand("xban_dbi", {
|
|||||||
privs = { server=true },
|
privs = { server=true },
|
||||||
func = function(name, params)
|
func = function(name, params)
|
||||||
if params == "--list" then
|
if params == "--list" then
|
||||||
local names = { }
|
local importers = { }
|
||||||
for name in pairs(xban.importers) do
|
for importer in pairs(xban.importers) do
|
||||||
table.insert(names, name)
|
table.insert(importers, importer)
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
("[xban] Known importers: %s"):format(
|
("[xban] Known importers: %s"):format(
|
||||||
table.concat(names, ", ")))
|
table.concat(importers, ", ")))
|
||||||
return
|
return
|
||||||
elseif not xban.importers[params] then
|
elseif not xban.importers[params] then
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
|
@ -8,19 +8,19 @@ function xban.importers.v2()
|
|||||||
local text = f:read("*a")
|
local text = f:read("*a")
|
||||||
f:close()
|
f:close()
|
||||||
local db = minetest.deserialize(text)
|
local db = minetest.deserialize(text)
|
||||||
for _, e in ipairs(db) do
|
for _, ent in ipairs(db) do
|
||||||
for name in pairs(e.names) do
|
for name in pairs(ent.names) do
|
||||||
local entry = xban.find_entry(name, true)
|
local entry = xban.find_entry(name, true)
|
||||||
if entry.source ~= "xban:importer_v2" then
|
if entry.source ~= "xban:importer_v2" then
|
||||||
for nm in pairs(e.names) do
|
for nm in pairs(e.names) do
|
||||||
entry.names[nm] = true
|
entry.names[nm] = true
|
||||||
end
|
end
|
||||||
if e.banned then
|
if ent.banned then
|
||||||
entry.banned = true
|
entry.banned = true
|
||||||
entry.reason = e.banned
|
entry.reason = e.banned
|
||||||
entry.source = "xban:importer_v2"
|
entry.source = "xban:importer_v2"
|
||||||
entry.time = e.time
|
entry.time = ent.time
|
||||||
entry.expires = e.expires
|
entry.expires = ent.expires
|
||||||
table.insert(entry.record, {
|
table.insert(entry.record, {
|
||||||
source = entry.source,
|
source = entry.source,
|
||||||
reason = entry.reason,
|
reason = entry.reason,
|
||||||
|
10
init.lua
10
init.lua
@ -24,9 +24,7 @@ local function make_logger(level)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local ACTION = make_logger("action")
|
local ACTION = make_logger("action")
|
||||||
local INFO = make_logger("info")
|
|
||||||
local WARNING = make_logger("warning")
|
local WARNING = make_logger("warning")
|
||||||
local ERROR = make_logger("error")
|
|
||||||
|
|
||||||
local unit_to_secs = {
|
local unit_to_secs = {
|
||||||
s = 1, m = 60, h = 3600,
|
s = 1, m = 60, h = 3600,
|
||||||
@ -299,11 +297,11 @@ minetest.register_chatcommand("xban_wl", {
|
|||||||
local cmd, plname = params:match("%s*(%S+)%s*(%S+)")
|
local cmd, plname = params:match("%s*(%S+)%s*(%S+)")
|
||||||
if cmd == "add" then
|
if cmd == "add" then
|
||||||
xban.add_whitelist(plname, name)
|
xban.add_whitelist(plname, name)
|
||||||
ACTION("%s adds %s to whitelist", source, plname)
|
ACTION("%s adds %s to whitelist", name, plname)
|
||||||
return true, "Added to whitelist: "..plname
|
return true, "Added to whitelist: "..plname
|
||||||
elseif cmd == "del" then
|
elseif cmd == "del" then
|
||||||
xban.remove_whitelist(plname)
|
xban.remove_whitelist(plname)
|
||||||
ACTION("%s removes %s to whitelist", source, plname)
|
ACTION("%s removes %s to whitelist", name, plname)
|
||||||
return true, "Removed from whitelist: "..plname
|
return true, "Removed from whitelist: "..plname
|
||||||
elseif cmd == "get" then
|
elseif cmd == "get" then
|
||||||
local e = xban.get_whitelist(plname)
|
local e = xban.get_whitelist(plname)
|
||||||
@ -361,10 +359,10 @@ local function load_db()
|
|||||||
WARNING("Unable to load database: %s", "Read failed")
|
WARNING("Unable to load database: %s", "Read failed")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local t, e = minetest.deserialize(cont)
|
local t, e2 = minetest.deserialize(cont)
|
||||||
if not t then
|
if not t then
|
||||||
WARNING("Unable to load database: %s",
|
WARNING("Unable to load database: %s",
|
||||||
"Deserialization failed: "..(e or "unknown error"))
|
"Deserialization failed: "..(e2 or "unknown error"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
db = t
|
db = t
|
||||||
|
Loading…
Reference in New Issue
Block a user