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