9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-24 01:29:16 +00:00

Cleanup SRC

This commit is contained in:
Daniel Mills
2021-07-14 02:34:13 -04:00
parent f29015426f
commit 6ca6fc6989
605 changed files with 53283 additions and 64305 deletions

View File

@@ -8,258 +8,215 @@ import java.io.File;
import java.io.IOException;
@Data
public class IrisSettings
{
public static transient IrisSettings settings;
private IrisSettingsCache cache = new IrisSettingsCache();
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
private IrisSettingsParallax parallax = new IrisSettingsParallax();
private IrisSettingsGeneral general = new IrisSettingsGeneral();
private IrisSettingsGUI gui = new IrisSettingsGUI();
private IrisSettingsGenerator generator = new IrisSettingsGenerator();
private IrisSettingsStudio studio = new IrisSettingsStudio();
public class IrisSettings {
public static transient IrisSettings settings;
private IrisSettingsCache cache = new IrisSettingsCache();
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
private IrisSettingsParallax parallax = new IrisSettingsParallax();
private IrisSettingsGeneral general = new IrisSettingsGeneral();
private IrisSettingsGUI gui = new IrisSettingsGUI();
private IrisSettingsGenerator generator = new IrisSettingsGenerator();
private IrisSettingsStudio studio = new IrisSettingsStudio();
@DontObfuscate
public int configurationVersion = 3;
@DontObfuscate
public int configurationVersion = 3;
public boolean isStudio() {
return getStudio().isStudio();
}
public boolean isStudio() {
return getStudio().isStudio();
}
public boolean isUseServerLaunchedGuis() {
return getGui().isUseServerLaunchedGuis();
}
public boolean isUseServerLaunchedGuis() {
return getGui().isUseServerLaunchedGuis();
}
public long getParallaxRegionEvictionMS() {
return getParallax().getParallaxRegionEvictionMS();
}
public long getParallaxRegionEvictionMS() {
return getParallax().getParallaxRegionEvictionMS();
}
@Data
public static class IrisSettingsCache
{
@DontObfuscate
public int streamingCacheSize = 8192;
}
@Data
public static class IrisSettingsCache {
@DontObfuscate
public int streamingCacheSize = 8192;
}
@Data
public static class IrisSettingsConcurrency
{
@DontObfuscate
public int threadCount = -1;
}
@Data
public static class IrisSettingsConcurrency {
@DontObfuscate
public int threadCount = -1;
}
@Data
public static class IrisSettingsParallax
{
@DontObfuscate
public int parallaxRegionEvictionMS = 15000;
@Data
public static class IrisSettingsParallax {
@DontObfuscate
public int parallaxRegionEvictionMS = 15000;
@DontObfuscate
public int parallaxChunkEvictionMS = 5000;
}
@DontObfuscate
public int parallaxChunkEvictionMS = 5000;
}
@Data
public static class IrisSettingsGeneral
{
@Data
public static class IrisSettingsGeneral {
@DontObfuscate
public boolean commandSounds = true;
@DontObfuscate
public boolean commandSounds = true;
@DontObfuscate
public boolean verbose = false;
@DontObfuscate
public boolean verbose = false;
@DontObfuscate
public boolean ignoreWorldEdit = false;
@DontObfuscate
public boolean ignoreWorldEdit = false;
@DontObfuscate
public boolean disableNMS = false;
@DontObfuscate
public boolean disableNMS = false;
@DontObfuscate
public boolean pluginMetrics = true;
@DontObfuscate
public boolean pluginMetrics = true;
@DontObfuscate
public boolean splashLogoStartup = true;
}
@DontObfuscate
public boolean splashLogoStartup = true;
}
@Data
public static class IrisSettingsGUI
{
@DontObfuscate
public boolean useServerLaunchedGuis = true;
@Data
public static class IrisSettingsGUI {
@DontObfuscate
public boolean useServerLaunchedGuis = true;
@DontObfuscate
public boolean maximumPregenGuiFPS = false;
@DontObfuscate
public boolean maximumPregenGuiFPS = false;
@DontObfuscate
public boolean localPregenGui = true;
}
@DontObfuscate
public boolean localPregenGui = true;
}
@Data
public static class IrisSettingsGenerator
{
@DontObfuscate
public String defaultWorldType = "overworld";
@Data
public static class IrisSettingsGenerator {
@DontObfuscate
public String defaultWorldType = "overworld";
@DontObfuscate
public boolean mcaPregenerator = false;
@DontObfuscate
public boolean mcaPregenerator = false;
@DontObfuscate
public boolean systemEffects = true;
@DontObfuscate
public boolean systemEffects = true;
@DontObfuscate
public boolean systemEntitySpawnOverrides = true;
@DontObfuscate
public boolean systemEntitySpawnOverrides = true;
@DontObfuscate
public boolean systemEntityInitialSpawns = true;
@DontObfuscate
public boolean systemEntityInitialSpawns = true;
@DontObfuscate
public int maxBiomeChildDepth = 5;
@DontObfuscate
public int maxBiomeChildDepth = 5;
}
}
@Data
public static class IrisSettingsStudio
{
@Data
public static class IrisSettingsStudio {
@DontObfuscate
public boolean studio = true;
@DontObfuscate
public boolean studio = true;
@DontObfuscate
public boolean openVSCode = true;
@DontObfuscate
public boolean openVSCode = true;
@DontObfuscate
public boolean disableTimeAndWeather = true;
}
@DontObfuscate
public boolean disableTimeAndWeather = true;
}
public static IrisSettings get()
{
if(settings != null)
{
return settings;
}
public static IrisSettings get() {
if (settings != null) {
return settings;
}
IrisSettings defaults = new IrisSettings();
JSONObject def = new JSONObject(new Gson().toJson(defaults));
if(settings == null)
{
settings = new IrisSettings();
IrisSettings defaults = new IrisSettings();
JSONObject def = new JSONObject(new Gson().toJson(defaults));
if (settings == null) {
settings = new IrisSettings();
File s = Iris.instance.getDataFile("settings.json");
File s = Iris.instance.getDataFile("settings.json");
if(!s.exists())
{
try
{
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
}
if (!s.exists()) {
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} catch (JSONException | IOException e) {
e.printStackTrace();
}
} else {
try {
String ss = IO.readAll(s);
settings = new Gson().fromJson(ss, IrisSettings.class);
catch(JSONException | IOException e)
{
e.printStackTrace();
}
}
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);
}
}
else
{
try
{
String ss = IO.readAll(s);
settings = new Gson().fromJson(ss, IrisSettings.class);
for (String i : new KSet<>(j.keySet())) {
if (!def.has(i)) {
u = true;
j.remove(i);
Iris.warn("Removing unused config key: " + i);
}
}
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);
}
}
if (u) {
try {
IO.writeAll(s, j.toString(4));
Iris.info("Updated Configuration Files");
} catch (Throwable e) {
e.printStackTrace();
}
}
} catch (Throwable 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...");
for(String i : new KSet<>(j.keySet()))
{
if(!def.has(i))
{
u = true;
j.remove(i);
Iris.warn("Removing unused config key: " + i);
}
}
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
Iris.info("Configuration Fixed!");
} catch (IOException 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!");
}
}
});
} catch (Throwable 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...");
if(u)
{
try
{
IO.writeAll(s, j.toString(4));
Iris.info("Updated Configuration Files");
}
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
Iris.info("Configuration Fixed!");
} catch (IOException 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!");
}
}
}
catch(Throwable e)
{
e.printStackTrace();
}
}
}
if (!s.exists()) {
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
} catch (JSONException | IOException e) {
e.printStackTrace();
}
}
}
catch(Throwable 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...");
return settings;
}
try {
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
Iris.info("Configuration Fixed!");
} catch (IOException 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!");
}
}
});
}
catch(Throwable 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) {
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!");
}
}
}
if(!s.exists())
{
try
{
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
}
catch(JSONException | IOException e)
{
e.printStackTrace();
}
}
}
return settings;
}
public static void invalidate()
{
synchronized(settings)
{
settings = null;
}
}
public static void invalidate() {
synchronized (settings) {
settings = null;
}
}
}