From 8eb4437ac86270728c8ee460088cb3bf49b92eb3 Mon Sep 17 00:00:00 2001 From: Zemtzov7 <72821250+zmv7@users.noreply.github.com> Date: Tue, 20 Dec 2022 22:41:01 +0500 Subject: [PATCH] Fix crash if `/home` is executed with an invalid name (#3000) --- mods/sethome/init.lua | 7 +++++++ mods/sethome/locale/sethome.ru.tr | 1 + 2 files changed, 8 insertions(+) diff --git a/mods/sethome/init.lua b/mods/sethome/init.lua index 9fc8e6ac..19de9581 100644 --- a/mods/sethome/init.lua +++ b/mods/sethome/init.lua @@ -52,6 +52,9 @@ end sethome.get = function(name) local player = minetest.get_player_by_name(name) + if not player then + return false, S("This command can only be executed in-game!") + end local player_meta = player:get_meta() local pos = minetest.string_to_pos(player_meta:get_string("sethome:home")) if pos then @@ -86,6 +89,10 @@ minetest.register_chatcommand("home", { description = S("Teleport you to your home point"), privs = {home = true}, func = function(name) + local player = minetest.get_player_by_name(name) + if not player then + return false, S("This command can only be executed in-game!") + end if sethome.go(name) then return true, S("Teleported to home!") end diff --git a/mods/sethome/locale/sethome.ru.tr b/mods/sethome/locale/sethome.ru.tr index 67388245..2b465a30 100644 --- a/mods/sethome/locale/sethome.ru.tr +++ b/mods/sethome/locale/sethome.ru.tr @@ -6,3 +6,4 @@ Set a home using /sethome=Установите домашнюю точку, ис Set your home point=Установите вашу домашнюю точку Home set!=Домашняя точка установлена! Player not found!=Игрок не обнаружен! +This command can only be executed in-game!=Эта команда может быть использована только в игре!