mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-02 07:56:48 +00:00
fix getEngineData NullPointer
This commit is contained in:
parent
25b41fe62c
commit
d0688782b1
@ -254,30 +254,40 @@ public class IrisEngine implements Engine {
|
|||||||
return engineData.aquire(() -> {
|
return engineData.aquire(() -> {
|
||||||
//TODO: Method this file
|
//TODO: Method this file
|
||||||
File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + ".json");
|
File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + ".json");
|
||||||
|
IrisEngineData data = null;
|
||||||
|
|
||||||
if (!f.exists()) {
|
if (f.exists()) {
|
||||||
try {
|
try {
|
||||||
f.getParentFile().mkdirs();
|
data = new Gson().fromJson(IO.readAll(f), IrisEngineData.class);
|
||||||
IrisEngineData data = new IrisEngineData();
|
if (data == null) {
|
||||||
data.getStatistics().setVersion(Iris.instance.getIrisVersion());
|
Iris.error("Failed to read Engine Data! Corrupted File? recreating...");
|
||||||
data.getStatistics().setMCVersion(Iris.instance.getMCVersion());
|
|
||||||
data.getStatistics().setUpgradedVersion(Iris.instance.getIrisVersion());
|
|
||||||
if (data.getStatistics().getVersion() == -1 || data.getStatistics().getMCVersion() == -1 ) {
|
|
||||||
Iris.error("Failed to setup Engine Data!");
|
|
||||||
}
|
}
|
||||||
IO.writeAll(f, new Gson().toJson(data));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (data == null) {
|
||||||
return new Gson().fromJson(IO.readAll(f), IrisEngineData.class);
|
data = new IrisEngineData();
|
||||||
} catch (Throwable e) {
|
data.getStatistics().setVersion(Iris.instance.getIrisVersion());
|
||||||
e.printStackTrace();
|
data.getStatistics().setMCVersion(Iris.instance.getMCVersion());
|
||||||
|
data.getStatistics().setUpgradedVersion(Iris.instance.getIrisVersion());
|
||||||
|
if (data.getStatistics().getVersion() == -1 || data.getStatistics().getMCVersion() == -1 ) {
|
||||||
|
Iris.error("Failed to setup Engine Data!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f.getParentFile().exists() || f.getParentFile().mkdirs()) {
|
||||||
|
try {
|
||||||
|
IO.writeAll(f, new Gson().toJson(data));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Iris.error("Failed to setup Engine Data!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new IrisEngineData();
|
return data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user