Config tweaks

This commit is contained in:
cyberpwn 2021-08-21 05:56:15 -04:00
parent e752a48343
commit d3998dd03b
3 changed files with 9 additions and 63 deletions

View File

@ -18,6 +18,7 @@
package com.volmit.iris;
import com.google.gson.Gson;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.command.CommandIris;
import com.volmit.iris.core.command.PermissionIris;
@ -677,7 +678,7 @@ public class Iris extends VolmitPlugin implements Listener {
}
public boolean isMCA() {
return !IrisSettings.get().getGenerator().isDisableMCA();
return IrisSettings.get().getGenerator().isHeadlessPregeneration();
}
public static void reportErrorChunk(int x, int z, Throwable e, String extra) {

View File

@ -101,7 +101,6 @@ public class IrisSettings {
public static class IrisSettingsGeneral {
public boolean commandSounds = true;
public boolean debug = false;
public boolean verbose = false;
public boolean ignoreWorldEdit = false;
public boolean disableNMS = false;
public boolean keepProductionOnReload = false;
@ -115,7 +114,6 @@ public class IrisSettings {
@Data
public static class IrisSettingsGUI {
public boolean useServerLaunchedGuis = true;
public boolean maximumPregenGuiFPS = false;
public boolean localPregenGui = true;
@ -124,10 +122,8 @@ public class IrisSettings {
@Data
public static class IrisSettingsGenerator {
public String defaultWorldType = "overworld";
public boolean disableMCA = false;
public boolean headlessPregeneration = false;
public boolean systemEffects = true;
public boolean systemEntitySpawnOverrides = true;
public boolean systemEntityInitialSpawns = true;
public int maxBiomeChildDepth = 4;
public boolean preventLeafDecay = true;
}
@ -162,65 +158,14 @@ public class IrisSettings {
try {
String ss = IO.readAll(s);
settings = new Gson().fromJson(ss, IrisSettings.class);
J.a(() ->
{
try {
JSONObject j = new JSONObject(ss);
boolean u = false;
for (String i : def.keySet()) {
if (!j.has(i)) {
u = true;
j.put(i, def.get(i));
Iris.warn("Adding new config key: " + i);
}
}
for (String i : new KSet<>(j.keySet())) {
if (!def.has(i)) {
u = true;
j.remove(i);
Iris.warn("Removing unused config key: " + i);
}
}
if (u) {
try {
IO.writeAll(s, j.toString(4));
Iris.info("Updated Configuration Files");
} catch (Throwable e) {
e.printStackTrace();
Iris.reportError(e);
}
}
} catch (Throwable ee) {
Iris.reportError(ee);
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
Iris.warn("Attempting to fix configuration while retaining valid in-memory settings...");
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
Iris.info("Configuration Fixed!");
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
Iris.error("ERROR! CONFIGURATION IMPOSSIBLE TO READ! Using an unmodifiable configuration from memory. Please delete the settings.json at some point to try to restore configurability!");
}
}
});
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} catch (IOException e) {
e.printStackTrace();
}
} catch (Throwable ee) {
Iris.reportError(ee);
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
Iris.warn("Attempting to fix configuration while retaining valid in-memory settings...");
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
Iris.info("Configuration Fixed!");
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
Iris.error("ERROR! CONFIGURATION IMPOSSIBLE TO READ! Using an unmodifiable configuration from memory. Please delete the settings.json at some point to try to restore configurability!");
}
}
}

View File

@ -42,7 +42,7 @@ public class HybridPregenMethod implements PregeneratorMethod {
}
private boolean supportsHeadless(World world) {
return IrisToolbelt.access(world) != null && !IrisSettings.get().getGenerator().isDisableMCA();
return IrisToolbelt.access(world) != null && IrisSettings.get().getGenerator().isHeadlessPregeneration();
}
@Override