fix crash when achievements are disabled and /awards is being used
This commit fixes https://git.minetest.land/MineClone2/MineClone2/issues/2164, which crashes the game whenever /awards is called with arguments other than enablebonemeal
parent
a27abae045
commit
390802a344
|
@ -21,9 +21,13 @@ minetest.register_chatcommand("awards", {
|
||||||
description = S("Show, clear, disable or enable your achievements"),
|
description = S("Show, clear, disable or enable your achievements"),
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
if param == "clear" then
|
if param == "clear" then
|
||||||
awards.clear_player(name)
|
if awards.player(name).disabled ~= nil then
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name, S("Awards are disabled, enable them first by using /awards enable!"))
|
||||||
S("All your awards and statistics have been cleared. You can now start again."))
|
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
|
||||||
elseif param == "disable" then
|
elseif param == "disable" then
|
||||||
awards.disable(name)
|
awards.disable(name)
|
||||||
minetest.chat_send_player(name, S("You have disabled your achievements."))
|
minetest.chat_send_player(name, S("You have disabled your achievements."))
|
||||||
|
@ -31,9 +35,17 @@ minetest.register_chatcommand("awards", {
|
||||||
awards.enable(name)
|
awards.enable(name)
|
||||||
minetest.chat_send_player(name, S("You have enabled your achievements."))
|
minetest.chat_send_player(name, S("You have enabled your achievements."))
|
||||||
elseif param == "c" then
|
elseif param == "c" then
|
||||||
awards.show_to(name, name, nil, true)
|
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
|
else
|
||||||
awards.show_to(name, name, nil, false)
|
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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue