From 0c8db3e556944222b830d60e9edc61c411c24c4b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 14 Mar 2019 12:08:11 +0100 Subject: [PATCH] Fix crash in craftguide when player leaves --- mods/HELP/mcl_craftguide/init.lua | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/mods/HELP/mcl_craftguide/init.lua b/mods/HELP/mcl_craftguide/init.lua index 37087de0c..9fed76422 100644 --- a/mods/HELP/mcl_craftguide/init.lua +++ b/mods/HELP/mcl_craftguide/init.lua @@ -969,16 +969,6 @@ end M.register_on_mods_loaded(get_init_items) -M.register_on_joinplayer(function(player) - local name = player:get_player_name() - init_data(name) -end) - -M.register_on_leaveplayer(function(player) - local name = player:get_player_name() - player_data[name] = nil -end) - -- TODO: Remove sfinv support if sfinv_only then sfinv.register_page("craftguide:craftguide", { @@ -1106,6 +1096,8 @@ if progressive_mode then mcl_craftguide.add_recipe_filter("Default progressive filter", progressive_filter) M.register_on_joinplayer(function(player) + local name = player:get_player_name() + init_data(name) local meta = player:get_meta() local name = player:get_player_name() local data = player_data[name] @@ -1121,7 +1113,11 @@ if progressive_mode then meta:set_string("inv_items", serialize(data.inv_items)) end - M.register_on_leaveplayer(save_meta) + M.register_on_leaveplayer(function(player) + save_meta(player) + local name = player:get_player_name() + player_data[name] = nil + end) M.register_on_shutdown(function() local players = M.get_connected_players() @@ -1130,6 +1126,16 @@ if progressive_mode then save_meta(player) end end) +else + M.register_on_joinplayer(function(player) + local name = player:get_player_name() + init_data(name) + end) + + M.register_on_leaveplayer(function(player) + local name = player:get_player_name() + player_data[name] = nil + end) end function mcl_craftguide.show(name)