2023-05-05 17:05:07 +03:00
|
|
|
-- translation
|
|
|
|
local S = minetest.get_translator("mail")
|
|
|
|
|
2019-09-16 09:06:54 +03:00
|
|
|
minetest.register_on_joinplayer(function(player)
|
|
|
|
minetest.after(2, function(name)
|
2023-03-29 18:25:01 +03:00
|
|
|
local entry = mail.get_storage_entry(name)
|
|
|
|
local messages = entry.inbox
|
2023-04-01 20:14:53 +03:00
|
|
|
mail.hud_update(name, messages)
|
2019-09-16 09:06:54 +03:00
|
|
|
|
|
|
|
local unreadcount = 0
|
|
|
|
|
|
|
|
for _, message in pairs(messages) do
|
2023-04-01 20:14:53 +03:00
|
|
|
if not message.read then
|
2019-09-16 09:06:54 +03:00
|
|
|
unreadcount = unreadcount + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-05-05 12:38:19 +03:00
|
|
|
if unreadcount > 0 and mail.get_setting(name, "onjoin_notifications") then
|
2019-09-16 09:06:54 +03:00
|
|
|
minetest.chat_send_player(name,
|
2023-05-05 17:05:07 +03:00
|
|
|
minetest.colorize("#00f529", "(" .. unreadcount .. ") " .. S("You have mail! Type /mail to read")))
|
2019-09-16 09:06:54 +03:00
|
|
|
end
|
|
|
|
end, player:get_player_name())
|
|
|
|
end)
|