Use builtin split func in storage.lua

This commit is contained in:
Athozus 2023-03-11 14:26:44 +01:00
parent 30a11784a9
commit a2b74be394
No known key found for this signature in database
GPG key ID: B50895022E8484BF
2 changed files with 7 additions and 7 deletions

View file

@ -702,7 +702,7 @@ function mail.handle_receivefields(player, formname, fields)
local recipients = mail.parse_player_list(fields.to)
local isNew = true
for r_,recipient in ipairs(recipients) do
if mail.split(recipient, "@")[1] == "" then -- in case of maillist
if recipient:split("@")[1] == "" then -- in case of maillist
isNew = false
else
for c_,contact in ipairs(contacts) do

View file

@ -248,9 +248,9 @@ function mail.addMaillist(maillist, players_string)
table.insert(maillists, 1, maillist)
if mail.write_json_file(mail.maildir .. "/mail.maillists.json", maillists) then
-- add status for players contained in the maillist
local players = mail.split(players_string,"\n")
local players = player_string:split("\n")
for _, player in ipairs(players) do
local playerInfo = mail.split(player, " ")
local playerInfo = player:split(" ")
if minetest.player_exists(playerInfo[1]) then -- avoid blank names
mail.addPlayerToMaillist(playerInfo[1], maillist.id, playerInfo[2])
end
@ -275,9 +275,9 @@ function mail.setMaillist(ml_id, updated_maillist, players_string)
-- remove all players
mail.removePlayersFromMaillist(maillist_id)
-- to add those registered in the updated maillist
local players = mail.split(players_string,"\n")
local players = players_string:split("\n")
for _, player in ipairs(players) do
local playerInfo = mail.split(player, " ")
local playerInfo = player:split(" ")
if minetest.player_exists(playerInfo[1]) then -- avoid blank names
mail.addPlayerToMaillist(playerInfo[1], maillist_id, playerInfo[2])
end
@ -398,12 +398,12 @@ function mail.deleteMaillist(ml_id)
end
function mail.extractMaillists(receivers)
local globalReceivers = mail.split(receivers,",") -- receivers including maillists
local globalReceivers = receivers:split(",") -- receivers including maillists
local receivers = {} -- extracted receivers
-- extract players from mailing lists
for _, receiver in ipairs(globalReceivers) do
local receiverInfo = mail.split(receiver, "@") -- @maillist
local receiverInfo = receiver:split("@") -- @maillist
if receiverInfo[1] == "" and receiverInfo[2] then -- in case of maillist
local players_ml = mail.getPlayersInMaillist(mail.getMaillistIdFromName(receiverInfo[2]))
if players_ml then