From a358888ca1720ef4ec88e84ef98e819810aa2d55 Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Thu, 6 Jun 2019 15:23:36 +0200 Subject: [PATCH] nil check and safe alloc --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 0f53c18..388cd76 100644 --- a/init.lua +++ b/init.lua @@ -99,7 +99,7 @@ minetest.register_on_joinplayer(function(player) local str = player:get_attribute("beerchat:channels") if str and str ~= "" then playersChannels[player:get_player_name()] = {} - playersChannels[player:get_player_name()] = minetest.parse_json(str) + playersChannels[player:get_player_name()] = minetest.parse_json(str) or {} else playersChannels[player:get_player_name()] = {} playersChannels[player:get_player_name()][main_channel_name] = "joined" @@ -655,7 +655,7 @@ minetest.register_on_chat_message(function(name, message) if player:is_player() then local target = player:get_player_name() -- Checking if the target is in this channel - if playersChannels[target][main_channel_name] then + if playersChannels[target] and playersChannels[target][main_channel_name] then if not minetest.get_player_by_name(target):get_attribute("beerchat:muted:"..name) then minetest.chat_send_player(target, format_message(whisper_string, { channel_name = main_channel_name, from_player = name, message = msg, color = whisper_color