Add nil check after reading world data file

Closes: https://github.com/AntumMT/mod-cleaner/issues/3
This commit is contained in:
Jordan Irwin 2025-01-18 02:47:43 -08:00
parent ecf5201220
commit f35e2f1808
No known key found for this signature in database
GPG key ID: E3E358C2F44C290A
2 changed files with 7 additions and 1 deletions

View file

@ -7,6 +7,7 @@
v1.2.1 v1.2.1
---- ----
- use sounds mod for sounds - use sounds mod for sounds
- added nil check after reading world data file
v1.2 v1.2

View file

@ -28,8 +28,13 @@ local function get_world_data()
local wdata = {} local wdata = {}
local buffer = io.open(world_file, "r") local buffer = io.open(world_file, "r")
if buffer then if buffer then
wdata = core.parse_json(buffer:read("*a")) local err
wdata, err = core.parse_json(buffer:read("*a"), nil, true)
buffer:close() buffer:close()
if wdata == nil then
cleaner.log("warning", "reading world data file failed: " .. world_file)
wdata = {}
end
end end
local rem_types = {"entities", "nodes", "ores",} local rem_types = {"entities", "nodes", "ores",}