Merge pull request 'Fix crash related to awards' (#2884) from awards_crashfix into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2884
Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
cora 2022-10-31 22:55:05 +00:00
commit fb29abcd50
2 changed files with 16 additions and 22 deletions

@ -484,7 +484,7 @@ function awards.show_to(name, to, sid, text)
name = to
end
if name == to and awards.player(to).disabled then
minetest.chat_send_player(S("You've disabled awards. Type /awards enable to reenable."))
minetest.chat_send_player(name,S("You've disabled awards. Type /awards enable to reenable."))
return
end
if text then

@ -20,32 +20,26 @@ minetest.register_chatcommand("awards", {
params = S("[c|clear|disable|enable]"),
description = S("Show, clear, disable or enable your advancements."),
func = function(name, param)
if param == "enable" then
awards.enable(name)
minetest.chat_send_player(name, S("You have enabled your advancements."))
return
end
if awards.player(name).disabled then
minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!"))
return
end
if param == "clear" then
if awards.player(name).disabled ~= nil then
minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!"))
else
awards.clear_player(name)
minetest.chat_send_player(name,
S("All your awards and statistics have been cleared. You can now start again."))
end
awards.clear_player(name)
minetest.chat_send_player(name,
S("All your awards and statistics have been cleared. You can now start again."))
elseif param == "disable" then
awards.disable(name)
minetest.chat_send_player(name, S("You have disabled your advancements."))
elseif param == "enable" then
awards.enable(name)
minetest.chat_send_player(name, S("You have enabled your advancements."))
elseif param == "c" then
if awards.player(name).disabled ~= nil then
minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!"))
else
awards.show_to(name, name, nil, true)
end
else
if awards.player(name).disabled ~= nil then
minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!"))
else
awards.show_to(name, name, nil, false)
end
awards.show_to(name, name, nil, false)
end
end
})