Gently fail on new overworlds

This commit is contained in:
cyberpwn 2021-08-30 07:05:53 -04:00
parent 09edc78bdc
commit fbdb060e10
3 changed files with 18 additions and 11 deletions

View File

@ -263,6 +263,12 @@ public class Iris extends VolmitPlugin implements Listener {
for (File j : dims.listFiles()) {
if (j.getName().endsWith(".json")) {
IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]);
if(dim == null)
{
continue;
}
Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath());
if (dim.installDataPack(() -> data, dpacks)) {
reboot = true;
@ -358,6 +364,12 @@ public class Iris extends VolmitPlugin implements Listener {
if (j.getName().endsWith(".json")) {
IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]);
if(dim == null)
{
Iris.error("Failed to load " + j.getPath());
continue;
}
if (!verifyDataPackInstalled(dim)) {
bad = true;
}

View File

@ -103,6 +103,8 @@ public class IrisSettings {
public boolean pluginMetrics = true;
public boolean splashLogoStartup = true;
public boolean autoStartDefaultStudio = false;
public boolean useConsoleCustomColors = false;
public boolean useCustomColorsIngame = true;
public String forceMainWorld = "";
public int spinh = -20;
public int spins = 7;

View File

@ -441,20 +441,13 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
{
Iris.error("Failed to read " + typeToken.getRawType().getCanonicalName() + "... faking objects a little to load the file at least.");
try {
T o = (T) typeToken.getRawType().getConstructor().newInstance();
return o;
} catch (InstantiationException ex) {
ex.printStackTrace();
} catch (IllegalAccessException ex) {
ex.printStackTrace();
} catch (InvocationTargetException ex) {
ex.printStackTrace();
} catch (NoSuchMethodException ex) {
ex.printStackTrace();
return (T) typeToken.getRawType().getConstructor().newInstance();
} catch (Throwable ignored) {
}
}
return null;
}
}
};
}
}