nil check and safe alloc
This commit is contained in:
parent
eac3daba8e
commit
a358888ca1
4
init.lua
4
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user