Automatic Legacy Config Converter

This commit is contained in:
KAMKEEL committed 2023-01-07 18:07:23 -05:00
1 parent 0db7ef8e66
commit bc6cc35fd6
8 files changed
+487 -116

No files matched your search

@@ -2,7 +2,9 @@ package noppes.npcs.config;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import noppes.npcs.CustomNpcs;
import noppes.npcs.config.legacy.LegacyConfig;
import noppes.npcs.constants.EnumScriptType;
import org.apache.logging.log4j.Level;
@@ -12,14 +14,25 @@ public class ConfigDebug
{
public static Configuration config;
public final static String LOGGING = "Logging";
/**
* Logging Properties
**/
public static Property PlayerLoggingProperty;
public static boolean PlayerLogging = false;
public static Property ScriptLoggingProperty;
public static boolean ScriptLogging = false;
public static int ScriptFrequency = 20;
public static int ScriptIgnoreTime = 2000;
public static String ScriptLogIgnoreType = "TICK";
public final static String LOGGING = "Visual";
public static Property ScriptFrequencyProperty;
public static int ScriptFrequency = 20;
public static Property ScriptIgnoreTimeProperty;
public static int ScriptIgnoreTime = 2000;
public static Property ScriptLogIgnoreTypeProperty;
public static String ScriptLogIgnoreType = "TICK";
public static void init(File configFile)
{
@@ -28,24 +41,54 @@ public class ConfigDebug
try
{
config.load();
PlayerLogging = config.get(LOGGING, "Enable Player Logging", false, "Enables if Player Information (WAND-USE) should be printed to CustomNPCs Logs. IF on Server \n" +
"Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3").getBoolean(false);
ScriptLogging = config.get(LOGGING, "Enable Script Logging", false, "Enables if Scripting Information should be printed to CustomNPCs Logs. IF on Server \n" +
"Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3").getBoolean(false);
ScriptFrequency = config.get(LOGGING, "Script Log Frequency Limit", 20, "Amount of Messages marked as SPAM [5, 3000]. Lower Number means MORE accurate messages \n" +
"This frequency will determine if the log will print a line with [SPAM] to warn the console.").getInt(20);
// Logging
PlayerLoggingProperty = config.get(LOGGING, "Enable Player Logging", false, "Enables if Player Information (WAND-USE) should be printed to CustomNPCs Logs. IF on Server \n" +
"Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3");
PlayerLogging = PlayerLoggingProperty.getBoolean(false);
ScriptLoggingProperty = config.get(LOGGING, "Enable Script Logging", false, "Enables if Scripting Information should be printed to CustomNPCs Logs. IF on Server \n" +
"Logs will only be present SERVER-SIDE only in CustomNPCs-latest, -1, -2, and -3");
ScriptLogging = ScriptLoggingProperty.getBoolean(false);
ScriptFrequencyProperty = config.get(LOGGING, "Script Log Frequency Limit", 20, "Amount of Messages marked as SPAM [5, 3000]. Lower Number means MORE accurate messages \n" +
"This frequency will determine if the log will print a line with [SPAM] to warn the console.");
ScriptFrequency = ScriptFrequencyProperty.getInt(20);
ScriptIgnoreTimeProperty = config.get(LOGGING, "Script Ignore Time Buffer", 2000, "IN Milliseconds 1s = 1000s. If a recent LOG of the same event is SENT within this threshold it will be ignored.");
ScriptIgnoreTime = ScriptIgnoreTimeProperty.getInt(2000);
ScriptLogIgnoreTypeProperty = config.get(LOGGING, "Script Type Ignore", "TICK", "Comma separated list of NPC Script Types that will omit these from the logs,\n" +
"INIT,TICK,INTERACT,DIALOG,DAMAGED,KILLED,ATTACK,TARGET,COLLIDE,KILLS,DIALOG_CLOSE,TIMER");
ScriptLogIgnoreType = ScriptLogIgnoreTypeProperty.getString();
// Convert to Legacy
if(CustomNpcs.legacyExist) {
PlayerLogging = LegacyConfig.PlayerLogging;
PlayerLoggingProperty.set(PlayerLogging);
ScriptLogging = LegacyConfig.ScriptLogging;
ScriptLoggingProperty.set(ScriptLogging);
ScriptFrequency = LegacyConfig.ScriptFrequency;
ScriptFrequencyProperty.set(ScriptFrequency);
ScriptIgnoreTime = LegacyConfig.ScriptIgnoreTime;
ScriptIgnoreTimeProperty.set(ScriptIgnoreTime);
ScriptLogIgnoreType = LegacyConfig.ScriptLogIgnoreType;
ScriptLogIgnoreTypeProperty.set(ScriptLogIgnoreType);
}
if (ScriptFrequency < 5)
ScriptFrequency = 5;
if (ScriptFrequency > 3000)
ScriptFrequency = 3000;
ScriptIgnoreTime = config.get(LOGGING, "Script Ignore Time Buffer", 2000, "IN Milliseconds 1s = 1000s. If a recent LOG of the same event is SENT within this threshold it will be ignored.").getInt(2000);
if (ScriptIgnoreTime < 0)
ScriptIgnoreTime = 0;
ScriptLogIgnoreType = config.get(LOGGING, "Script Type Ignore", "TICK", "Comma separated list of NPC Script Types that will omit these from the logs,\n" +
"INIT,TICK,INTERACT,DIALOG,DAMAGED,KILLED,ATTACK,TARGET,COLLIDE,KILLS,DIALOG_CLOSE,TIMER").getString();
try {
String[] ignoreTypes = ScriptLogIgnoreType.split(",");
for (String s : ignoreTypes) {