mirror of
https://notabug.org/TenPlus1/protector.git
synced 2025-01-09 17:57:30 +01:00
add nil checks to /protector_replace command
This commit is contained in:
parent
1130f447a6
commit
38341294e7
38
admin.lua
38
admin.lua
@ -41,35 +41,29 @@ minetest.register_chatcommand("protector_replace", {
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
|
||||
if not param or param == "" then
|
||||
|
||||
if protector.replace_names ~= "" then
|
||||
|
||||
local names = protector.replace_names:split(" ")
|
||||
|
||||
minetest.chat_send_player(name,
|
||||
"Replacing Protector name '" .. names[1]
|
||||
.. "' with '" .. names[2] .. "'")
|
||||
|
||||
return
|
||||
else
|
||||
minetest.chat_send_player(name,
|
||||
"Usage: /protector_replace <owner name> <new owner name>")
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- reset list to empty
|
||||
if param == "-" then
|
||||
|
||||
minetest.chat_send_player(name,
|
||||
S("Name List Reset"))
|
||||
minetest.chat_send_player(name, S("Name List Reset"))
|
||||
|
||||
protector.replace_names = ""
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- show name info
|
||||
if param == ""
|
||||
and protector.replace_names ~= "" then
|
||||
|
||||
local names = protector.replace_names:split(" ")
|
||||
|
||||
minetest.chat_send_player(name,
|
||||
"Replacing Protector name '" .. (names[1] or "")
|
||||
.. "' with '" .. (names[2] or "").. "'")
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
protector.replace_names = param
|
||||
|
||||
end,
|
||||
@ -108,7 +102,7 @@ minetest.register_abm({
|
||||
|
||||
local names = protector.replace_names:split(" ")
|
||||
|
||||
if owner == names[1] then
|
||||
if names[1] and names[2] and owner == names[1] then
|
||||
|
||||
meta:set_string("owner", names[2])
|
||||
meta:set_string("infotext", "Protection (owned by " .. names[2] .. ")")
|
||||
|
Loading…
Reference in New Issue
Block a user