using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Cecil_Libraries.ANSI_Utils.Objects; using DiskCardGame; using InscryptionAPI.Card; using InscryptionAPI.Guid; using InscryptionAPI.Helpers; using JSONLoader3.Cores.JSONLoaderV1Support.Objects; using JSONLoader3.Cores.JSONLoaderV1Support.Schemas; using JSONLoader3.Cores.JSONLoaderV1Support.Utilities; using JSONLoader3.Peripheral.FILE_Loader; using JSONLoader3.Peripheral.ImageHandling; using JSONLoader3.Peripheral.JSON_LINT; using JSONLoader3.Peripheral.JSON_SCHEMA; using JSONLoader3.Peripheral.Tooltip_Parser; using JSONLoader3.Peripheral.XML_Parser; using JSONLoader3.Subperipheral.JSONLoader_Configuration; using Microsoft.CodeAnalysis; using Sirenix.Utilities; using UnityEngine; using UnityEngine.UIElements; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Chaosyr")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("This is the new Modulated and API Based system in which JSONLoader will run off of (and maybe a CSV loader too)")] [assembly: AssemblyFileVersion("3.0.0.0")] [assembly: AssemblyInformationalVersion("3.0.0-Nightly-0.0.5+4de26c46a77613e506dd58cf3a3be6cf05b4c20e")] [assembly: AssemblyProduct("JSON Loader v3")] [assembly: AssemblyTitle("JSON Loader v3")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace JSONLoader3 { [BepInPlugin("Chaosyr.MADH95.Inscryption.JSON.CSVLoader", "JSON_and_CSV_Loader", "3.0.0.00000005")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class JSONLoader3 : BaseUnityPlugin { public const string PluginGuid = "Chaosyr.MADH95.Inscryption.JSON.CSVLoader"; public const string PluginName = "JSON_and_CSV_Loader"; public const string PluginVersion = "3.0.0.00000005"; private static Color Error = new Color("Doubleline", "Red", false, true, false); private static Color Warning = new Color("Underlined", "Yellow", false, true, false); private static Color256 Information = new Color256("Bold", 230, false, false); private static Color256 Debug = new Color256("Dulled", 248, false, false); private static Color256 ExtendedInformation = new Color256("Italic", 228, false, false); private static Color256 SummaryInformation = new Color256("Framed", 219, false, false); private static ManualLogSource BepInExLogger; public void Awake() { BepInExLogger = ((BaseUnityPlugin)this).Logger; DefineConfiguration.DefineConfigs(((BaseUnityPlugin)this).Config); FormatLogger("info", "Initialization for JSONLoader3 and CSVLoader", "Finished Creating JSONLoader3 and CSVLoader Configuration"); FindFiles.FindFilesToLoad(); LoadFiles.LoadFoundFiles(); foreach (CardInfo item in CardUtils.allJLDRCardsPublic) { FormatLogger("info", "Initialization for JSONLoader3 and CSVLoader", "Successfully Loaded card: " + ((Object)item).name); } FormatLogger("info", "Initialization for JSONLoader3 and CSVLoader", "Finished Loading JSONLoader, JSONLoader2, JSONLoader3 and CSVLoader."); } public static void FormatLogger(string level, string source, string message) { if (level.ToLower() == "error") { Console.WriteLine(((ColorBase)Error).Format() + "[(" + source + ") Error]: " + message + "\u001b[0m"); LogToBepInExFile((LogLevel)2, source, message); } else if (level.ToLower() == "warning") { Console.WriteLine(((ColorBase)Warning).Format() + "[(" + source + ") Warning]: " + message + "\u001b[0m"); LogToBepInExFile((LogLevel)4, source, message); } else if (level.ToLower() == "info" || level.ToLower() == "information") { Console.WriteLine(((ColorBase)Information).Format() + "[(" + source + ") Information]: " + message + "\u001b[0m"); LogToBepInExFile((LogLevel)16, source, message); } else if (level.ToLower() == "debug" && DefineConfiguration.ShowVerboseLogging.Value) { Console.WriteLine(((ColorBase)Debug).Format() + "[(" + source + ") Debug]: " + message + "\u001b[0m"); LogToBepInExFile((LogLevel)32, source, message); } else if ((level.ToLower() == "additionalinfo" || level.ToLower() == "additionalinformation") && DefineConfiguration.ShowAdditionalInformation.Value) { Console.WriteLine(((ColorBase)ExtendedInformation).Format() + "[(" + source + ") Additional Information]: " + message + "\u001b[0m"); LogToBepInExFile((LogLevel)8, source, message); } else if (level.ToLower() == "summary" && DefineConfiguration.ShowSummary.Value) { Console.WriteLine(((ColorBase)SummaryInformation).Format() + "[(" + source + ") Summary Information]: " + message + "\u001b[0m"); LogToBepInExFile((LogLevel)8, source, message); } } private static void LogToBepInExFile(LogLevel level, string source, string message) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown ManualLogSource val = new ManualLogSource("Chaosyr.MADH95.Inscryption.JSON.CSVLoader"); LogEventArgs e = new LogEventArgs((object)$"[({source}) {level}]: {message}", level, (ILogSource)(object)val); foreach (ILogListener listener in Logger.Listeners) { if (listener is DiskLogListener) { listener.LogEvent((object)typeof(JSONLoader3), e); } } } } } namespace JSONLoader3.Subperipheral.JSONLoader_Configuration { public class DefineConfiguration { public static ConfigEntry JSONLoadingPaths; public static ConfigEntry CSVLoadingPaths; public static ConfigEntry SchemaSavePath; public static ConfigEntry ShowVerboseLogging; public static ConfigEntry ShowAdditionalInformation; public static ConfigEntry ShowSummary; public static ConfigEntry toggleRecursiveOnPlugin; private static ConfigFile configFile; public static void DefineConfigs(ConfigFile config) { configFile = config; JSONLoadingPaths = configFile.Bind("Configuration", "JSON Loading Origination Path", "Scripts, Plugins/Scripts, Cards, Plugins/Cards", "These paths are case insensitive, and determine where JSON Scripts may be sourced from in order to load. If your a mod maker shipping mods, make a 'plugins' folder in your mods folder, and put a folder in there called 'scripts', this is where your JSON scripts should reside. If you need another path, you can override this value with your mod, we'll provide a system for you to do so."); CSVLoadingPaths = configFile.Bind("Configuration", "CSV Loading Origination Path", "Sheets, Plugins/Sheets", "These paths are case insensitive, and determine where CSV Sheets may be sourced from in order to load. If your a mod maker shipping mods, make a 'plugins' folder in your mods folder, and put a folder in there called 'sheets', this is where your CSV Sheets should reside. If you need another path, you can override this value with your mod, we'll provide a system for you to do so."); SchemaSavePath = configFile.Bind("Configuration", "Schema Save Path", "/Schemas", "This determines where JSON Schemas will be saved to as we create them, this path will be localized to the DLL's folder. You can use '../' to mean go up a folder."); JSONLoader3.FormatLogger("info", "Configuration", "Finished adding configuration for the Loading Paths associated with this mod."); ShowVerboseLogging = configFile.Bind("Logging", "Show Verbose Logging", false, "While this value is set to true, this API will show what is happening when its happening."); ShowAdditionalInformation = configFile.Bind("Logging", "Show Additional Information", false, "While this value is set to true, this API will show a more in depth lense as to what went wrong, and try to help explain why its wrong with links to references."); ShowSummary = configFile.Bind("Logging", "Show Summary Information", false, "While this value is set to true, this API will show the Summary for each property being verified by the Linter and some Additional Debug Information."); JSONLoader3.FormatLogger("info", "Configuration", "Finished adding configuration for the Logging associated with this mod."); toggleRecursiveOnPlugin = configFile.Bind("Compatibility", "Recursively Scan At Plugin Level", false, "While this value is set to true, this API will recursively scan for JSONs and CSVs from the Plugins level, rather than the set folders. This is defaulted to false for the purposes of keeping Load Times fast, but if you have a mod that isn't structured for this toggle this setting on."); JSONLoader3.FormatLogger("info", "Configuration", "Finished adding configuration for the Compatibility associated with this mod."); } } } namespace JSONLoader3.Peripheral.XML_Parser { public class ReadDocumentationFile { private static Assembly assembly = Assembly.GetExecutingAssembly(); internal static string DLLPath = Path.GetDirectoryName(assembly.Location); internal static string DLLName = Path.GetFileNameWithoutExtension(assembly.Location); internal static List DocFileXML = new List(); public static void FetchDocFile() { string dLLPath = DLLPath; char directorySeparatorChar = Path.DirectorySeparatorChar; if (File.Exists(dLLPath + directorySeparatorChar + DLLName + ".xml")) { string dLLPath2 = DLLPath; directorySeparatorChar = Path.DirectorySeparatorChar; StreamReader streamReader = new StreamReader(dLLPath2 + directorySeparatorChar + DLLName + ".xml"); while (streamReader.Peek() >= 0) { DocFileXML.Add(streamReader.ReadLine()); } } } public static List FetchItemSummary((string Namespace, string className, string ItemName) tup) { if (DocFileXML.Count == 0) { return null; } int num = DocFileXML.FindIndex((string x) => x.Contains("F:" + tup.Namespace + "." + tup.className + "." + tup.ItemName)); List list = new List(); for (int num2 = num + 1; num2 < DocFileXML.FindIndex(num, (string x) => x.Trim() == ""); num2++) { if (!(DocFileXML[num2].Trim() == "") && !(DocFileXML[num2].Trim() == "")) { list.Add(DocFileXML[num2]); } } return list; } public static string GetJSONSummary((string Namespace, string className, string ItemName) tup) { List list = FetchItemSummary((Namespace: tup.Namespace, className: tup.className, ItemName: tup.ItemName)); string text = ""; foreach (string item in list) { text = text + item.Trim() + " "; } return text.Trim(); } public static (string Namespace, string className, string ItemName) GetInfo(string ItemName) { string item = typeof(Class).Namespace; string name = typeof(Class).Name; return (Namespace: item, className: name, ItemName: ItemName); } public static (string Namespace, string className, string ItemName) GetInfo(string ItemName, Type Class) { string item = Class.Namespace; string name = Class.Name; return (Namespace: item, className: name, ItemName: ItemName); } public static string EscapeJSON(string value) { return value.Replace("\\", "\\\\").Replace("\"", "\\\""); } } } namespace JSONLoader3.Peripheral.Tooltip_Parser { public class TooltipDisector { public static List GetTooltipProperties(FieldInfo field) { List list = new List(); TooltipAttribute customAttribute = ((MemberInfo)field).GetCustomAttribute(); if (customAttribute == null) { return list; } string[] array = customAttribute.tooltip.Split(new char[1] { '|' }); foreach (string text in array) { StringBuilder stringBuilder = new StringBuilder(); int num = 0; string tooltip = customAttribute.tooltip; foreach (char c in tooltip) { if (c == '(') { num++; } if (c == ')') { num--; } if (c == '|' && num == 0) { list.Add(stringBuilder.ToString().Trim()); stringBuilder.Clear(); } else { stringBuilder.Append(c); } } if (stringBuilder.Length > 0) { list.Add(stringBuilder.ToString().Trim()); } } return list; } } } namespace JSONLoader3.Peripheral.JSON_SCHEMA { public class LoadSchema { public static string SchemaFolder; public static List FindAndLoadSchema(string LoaderName) { string fullSchemaPath = GetFullSchemaPath(LoaderName); FileStream stream = File.OpenRead(fullSchemaPath); StreamReader streamReader = new StreamReader(stream); List list = new List(); while (streamReader.Peek() >= 0) { string item = streamReader.ReadLine(); list.Add(item); } streamReader.Dispose(); return list; } public static string GetFullSchemaPath(string LoaderName) { string[] obj = new string[8] { SchemaFolder, null, null, null, null, null, null, null }; char directorySeparatorChar = Path.DirectorySeparatorChar; obj[1] = directorySeparatorChar.ToString(); obj[2] = LoaderName; directorySeparatorChar = Path.DirectorySeparatorChar; obj[3] = directorySeparatorChar.ToString(); obj[4] = LoaderName; obj[5] = "_"; obj[6] = typeof(Class).Name; obj[7] = "_Schema.json"; return string.Concat(obj); } static LoadSchema() { string dLLPath = FindFiles.DLLPath; char directorySeparatorChar = Path.DirectorySeparatorChar; SchemaFolder = dLLPath + directorySeparatorChar + DefineConfiguration.SchemaSavePath.Value; } } public class WriteSchema { public static string SchemaFolder; public static void CreateSchemaDirectors(string LoaderName) { if (!Directory.Exists(SchemaFolder)) { Directory.CreateDirectory(SchemaFolder); } string schemaFolder = SchemaFolder; char directorySeparatorChar = Path.DirectorySeparatorChar; if (!Directory.Exists(schemaFolder + directorySeparatorChar + LoaderName)) { string schemaFolder2 = SchemaFolder; directorySeparatorChar = Path.DirectorySeparatorChar; Directory.CreateDirectory(schemaFolder2 + directorySeparatorChar + LoaderName); } } public static StreamWriter CreateAndOpenSchema(string LoaderName) { string[] obj = new string[8] { SchemaFolder, null, null, null, null, null, null, null }; char directorySeparatorChar = Path.DirectorySeparatorChar; obj[1] = directorySeparatorChar.ToString(); obj[2] = LoaderName; directorySeparatorChar = Path.DirectorySeparatorChar; obj[3] = directorySeparatorChar.ToString(); obj[4] = LoaderName; obj[5] = "_"; obj[6] = typeof(Class).Name; obj[7] = "_Schema.json"; string path = string.Concat(obj); FileStream stream = File.Create(path); return new StreamWriter(stream); } public static void CloseWriterAndFile(StreamWriter Writer) { Writer.Dispose(); } public static List<(FieldInfo field, List tooltips)> GetToolTips(List fields) { List<(FieldInfo, List)> list = new List<(FieldInfo, List)>(); foreach (FieldInfo field in fields) { list.Add((field, TooltipDisector.GetTooltipProperties(field))); } return list; } public static List GetRequired(List<(FieldInfo field, List tooltips)> fieldTooltipList) { return (from x in fieldTooltipList where x.tooltips.Contains("REQUIRED", StringComparer.Ordinal) && !x.tooltips.Contains("EXCLUDED", StringComparer.Ordinal) select "\"" + x.field.Name + "\"").ToList(); } public static List<(FieldInfo field, List tooltips)> GetWritable(List<(FieldInfo field, List tooltips)> fieldTooltipList) { return fieldTooltipList.Where(((FieldInfo field, List tooltips) x) => !x.tooltips.Contains("EXCLUDED", StringComparer.Ordinal)).ToList(); } public static string HandleString(List<(FieldInfo field, List tooltips)> writableFields, FieldInfo field, List tooltips, int Indentation, Type Class) { string text = ""; text = text + "\r\n " + new string(' ', Indentation * 4) + "\"" + field.Name + "\": {\r\n " + new string(' ', Indentation * 4) + "\"type\": \"string\",\r\n " + new string(' ', Indentation * 4) + "\"description\": \"" + ReadDocumentationFile.EscapeJSON(ReadDocumentationFile.GetJSONSummary(ReadDocumentationFile.GetInfo(field.Name, Class))) + "\","; string text2 = tooltips.FirstOrDefault((string x) => x.IndexOf("MinimumLength", StringComparison.Ordinal) >= 0); if (text2 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"minLength\": " + text2.Split(new char[1] { '(' }).Last().Trim('(', ')') + ","; } string text3 = tooltips.FirstOrDefault((string x) => x.IndexOf("Pattern", StringComparison.Ordinal) >= 0); if (text3 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"pattern\": \"" + ReadDocumentationFile.EscapeJSON(text3.Substring(text3.IndexOf('(') + 1, text3.LastIndexOf(')') - text3.IndexOf('(') - 1)) + "\","; } string text4 = tooltips.FirstOrDefault((string x) => x.IndexOf("Default", StringComparison.Ordinal) >= 0); if (text4 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"default\": \"" + text4.Split(new char[1] { '(' }).Last().Trim('(', ')') + "\","; } string text5 = tooltips.FirstOrDefault((string x) => x.IndexOf("Enums", StringComparison.Ordinal) >= 0); if (text5 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"enum\": [\r\n " + new string(' ', Indentation * 4) + string.Join(", " + Environment.NewLine + " " + new string(' ', Indentation * 4), from x in text5.Split(new char[1] { '(' }).Last().Trim('(', ')') .Split(new char[1] { ',' }) select "\"" + x.Trim() + "\"") + "\r\n " + new string(' ', Indentation * 4) + "],"; } text = text.TrimEnd(Array.Empty()); text = text.TrimEnd(new char[1] { ',' }); text = text + "\r\n " + new string(' ', Indentation * 4) + "}"; if (writableFields.IndexOf((field, tooltips)) != writableFields.Count - 1) { text += ","; } return text; } public static string HandleInt(List<(FieldInfo field, List tooltips)> writableFields, FieldInfo field, List tooltips, int Indentation, Type Class) { string text = ""; text = text + "\r\n " + new string(' ', Indentation * 4) + "\"" + field.Name + "\": {\r\n " + new string(' ', Indentation * 4) + "\"type\": \"integer\",\r\n " + new string(' ', Indentation * 4) + "\"description\": \"" + ReadDocumentationFile.EscapeJSON(ReadDocumentationFile.GetJSONSummary(ReadDocumentationFile.GetInfo(field.Name, Class))) + "\","; string text2 = tooltips.FirstOrDefault((string x) => x.IndexOf("Default", StringComparison.Ordinal) >= 0); if (text2 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"default\": " + text2.Split(new char[1] { '(' }).Last().Trim('(', ')') + ","; } string text3 = tooltips.FirstOrDefault((string x) => x.IndexOf("Minimum", StringComparison.Ordinal) >= 0); if (text3 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"minimum\": " + text3.Split(new char[1] { '(' }).Last().Trim('(', ')') + ","; } string text4 = tooltips.FirstOrDefault((string x) => x.IndexOf("Maximum", StringComparison.Ordinal) >= 0); if (text4 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"maximum\": " + text4.Split(new char[1] { '(' }).Last().Trim('(', ')') + ","; } text = text.TrimEnd(Array.Empty()); text = text.TrimEnd(new char[1] { ',' }); text = text + "\r\n " + new string(' ', Indentation * 4) + "}"; if (writableFields.IndexOf((field, tooltips)) != writableFields.Count - 1) { text += ","; } return text; } public static string HandleBoolean(List<(FieldInfo field, List tooltips)> writableFields, FieldInfo field, List tooltips, int Indentation, Type Class) { string text = ""; text = text + "\r\n " + new string(' ', Indentation * 4) + "\"" + field.Name + "\": {\r\n " + new string(' ', Indentation * 4) + "\"type\": \"boolean\",\r\n " + new string(' ', Indentation * 4) + "\"description\": \"" + ReadDocumentationFile.EscapeJSON(ReadDocumentationFile.GetJSONSummary(ReadDocumentationFile.GetInfo(field.Name, Class))) + "\","; string text2 = tooltips.FirstOrDefault((string x) => x.IndexOf("Default", StringComparison.Ordinal) >= 0); if (text2 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"default\": " + text2.Split(new char[1] { '(' }).Last().Trim('(', ')') .ToLower() + ","; } text = text.TrimEnd(Array.Empty()); text = text.TrimEnd(new char[1] { ',' }); text = text + "\r\n " + new string(' ', Indentation * 4) + "}"; if (writableFields.IndexOf((field, tooltips)) != writableFields.Count - 1) { text += ","; } return text; } public static string HandleStringArray(List<(FieldInfo field, List tooltips)> writableFields, FieldInfo field, List tooltips, int Indentation, Type Class) { string text = ""; text = text + "\r\n " + new string(' ', Indentation * 4) + "\"" + field.Name + "\": {\r\n " + new string(' ', Indentation * 4) + "\"type\": \"array\",\r\n " + new string(' ', Indentation * 4) + "\"description\": \"" + ReadDocumentationFile.EscapeJSON(ReadDocumentationFile.GetJSONSummary(ReadDocumentationFile.GetInfo(field.Name, Class))) + "\","; string text2 = tooltips.FirstOrDefault((string x) => x.IndexOf("Items", StringComparison.Ordinal) >= 0); if (text2 != null && text2.Split(new char[1] { '(' }).Last().Trim('(', ')') .ToLower() == "true") { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"items\": {"; string text3 = tooltips.FirstOrDefault((string x) => x.IndexOf("ItemType", StringComparison.Ordinal) >= 0); if (text3 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"type\": \"" + text3.Split(new char[1] { '(' }).Last().Trim('(', ')') .ToLower() + "\","; } string text4 = tooltips.FirstOrDefault((string x) => x.IndexOf("Pattern", StringComparison.Ordinal) >= 0); if (text4 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"pattern\": \"" + ReadDocumentationFile.EscapeJSON(text4.Substring(text4.IndexOf('(') + 1, text4.LastIndexOf(')') - text4.IndexOf('(') - 1)) + "\","; } string text5 = tooltips.FirstOrDefault((string x) => x.IndexOf("Enums", StringComparison.Ordinal) >= 0); if (text5 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"enum\": [\r\n " + new string(' ', Indentation * 4) + string.Join(", " + Environment.NewLine + " " + new string(' ', Indentation * 4), from x in text5.Split(new char[1] { '(' }).Last().Trim('(', ')') .Split(new char[1] { ',' }) select "\"" + x.Trim() + "\"") + "\r\n " + new string(' ', Indentation * 4) + "],"; } text = text.TrimEnd(Array.Empty()); text = text.TrimEnd(new char[1] { ',' }); text = text + "\r\n " + new string(' ', Indentation * 4) + "},"; } string text6 = tooltips.FirstOrDefault((string x) => x.IndexOf("UniqueItems", StringComparison.Ordinal) >= 0); if (text6 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"uniqueItems\": " + text6.Split(new char[1] { '(' }).Last().Trim('(', ')') .ToLower() + ","; } text = text.TrimEnd(Array.Empty()); text = text.TrimEnd(new char[1] { ',' }); text = text + "\r\n " + new string(' ', Indentation * 4) + "}"; if (writableFields.IndexOf((field, tooltips)) != writableFields.Count - 1) { text += ","; } return text; } public static string HandleObjectArray(List<(FieldInfo field, List tooltips)> writableFields, FieldInfo field, List tooltips, int Indentation, Type Class) { Type type = field.FieldType.GetGenericArguments()[0]; string text = ""; text = text + "\r\n " + new string(' ', Indentation * 4) + "\"" + field.Name + "\": {\r\n " + new string(' ', Indentation * 4) + "\"type\": \"array\",\r\n " + new string(' ', Indentation * 4) + "\"description\": \"" + ReadDocumentationFile.EscapeJSON(ReadDocumentationFile.GetJSONSummary(ReadDocumentationFile.GetInfo(field.Name, Class))) + "\","; string text2 = tooltips.FirstOrDefault((string x) => x.IndexOf("Items", StringComparison.Ordinal) >= 0); if (text2 != null && text2.Split(new char[1] { '(' }).Last().Trim('(', ')') .ToLower() == "true") { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"items\": {"; string text3 = tooltips.FirstOrDefault((string x) => x.IndexOf("ItemType", StringComparison.Ordinal) >= 0); if (text3 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"type\": \"" + text3.Split(new char[1] { '(' }).Last().Trim('(', ')') .ToLower() + "\","; } string text4 = tooltips.FirstOrDefault((string x) => x.IndexOf("AdditionalProperties", StringComparison.Ordinal) >= 0); if (text4 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"additionalProperties\": " + text4.Split(new char[1] { '(' }).Last().Trim('(', ')') .ToLower() + ","; } string text5 = RecursiveWrite(type, Indentation + 3); text += text5; text = text.TrimEnd(Array.Empty()); text = text.TrimEnd(new char[1] { ',' }); text = text + "\r\n " + new string(' ', Indentation * 4) + "},"; } string text6 = tooltips.FirstOrDefault((string x) => x.IndexOf("UniqueItems", StringComparison.Ordinal) >= 0); if (text6 != null) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"uniqueItems\": " + text6.Split(new char[1] { '(' }).Last().Trim('(', ')') .ToLower() + ","; } text = text.TrimEnd(Array.Empty()); text = text.TrimEnd(new char[1] { ',' }); text = text + "\r\n " + new string(' ', Indentation * 4) + "}"; if (writableFields.IndexOf((field, tooltips)) != writableFields.Count - 1) { text += ","; } return text; } public static string HandleObject(List<(FieldInfo field, List tooltips)> writableFields, FieldInfo field, List tooltips, int Indentation, Type Class) { string text = ""; text = text + "\r\n " + new string(' ', Indentation * 4) + "\"" + field.Name + "\": {\r\n " + new string(' ', Indentation * 4) + "\"type\": \"object\",\r\n " + new string(' ', Indentation * 4) + "\"description\": \"" + ReadDocumentationFile.EscapeJSON(ReadDocumentationFile.GetJSONSummary(ReadDocumentationFile.GetInfo(field.Name, Class))) + "\","; string text2 = RecursiveWrite(field.FieldType, Indentation + 2); text += text2; text = text.TrimEnd(Array.Empty()); text = text.TrimEnd(new char[1] { ',' }); text = text + "\r\n " + new string(' ', Indentation * 4) + "}"; if (writableFields.IndexOf((field, tooltips)) != writableFields.Count - 1) { text += ","; } return text; } public static void WriteJSONSchema(string LoaderName) { CreateSchemaDirectors(LoaderName); StreamWriter streamWriter = CreateAndOpenSchema(LoaderName); streamWriter.Write("{\r\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\r\n \"$id\": \"https://github.com/MADH95/JSONLoader\",\r\n \"title\": \"New " + LoaderName + " " + typeof(Class).Name + "\",\r\n \"description\": \"Schema to verify the input data for a new " + LoaderName + " " + typeof(Class).Name + ".\",\r\n \"type\": \"object\",\r\n \"additionalProperties\": false,"); List<(FieldInfo, List)> toolTips = GetToolTips(typeof(Class).GetFields().ToList()); List required = GetRequired(toolTips); if (!LinqExtensions.IsNullOrEmpty((IList)required)) { streamWriter.Write("\r\n \"required\": [\r\n " + string.Join("," + Environment.NewLine + " ", required) + "\r\n ],"); } streamWriter.Write("\r\n \"properties\": {"); List<(FieldInfo, List)> writable = GetWritable(toolTips); foreach (var (fieldInfo, tooltips) in writable) { if (fieldInfo.FieldType == typeof(string)) { streamWriter.Write(HandleString(writable, fieldInfo, tooltips, 0, typeof(Class))); } else if (fieldInfo.FieldType == typeof(int)) { streamWriter.Write(HandleInt(writable, fieldInfo, tooltips, 0, typeof(Class))); } else if (fieldInfo.FieldType == typeof(bool)) { streamWriter.Write(HandleBoolean(writable, fieldInfo, tooltips, 0, typeof(Class))); } else if (fieldInfo.FieldType == typeof(List)) { streamWriter.Write(HandleStringArray(writable, fieldInfo, tooltips, 0, typeof(Class))); } else if (fieldInfo.FieldType.IsGenericType && fieldInfo.FieldType.GetGenericTypeDefinition() == typeof(List<>)) { streamWriter.Write(HandleObjectArray(writable, fieldInfo, tooltips, 0, typeof(Class))); } else if (fieldInfo.FieldType.IsClass) { streamWriter.Write(HandleObject(writable, fieldInfo, tooltips, 0, typeof(Class))); } } streamWriter.Write("\r\n }\r\n}"); CloseWriterAndFile(streamWriter); } public static string RecursiveWrite(Type Class, int Indentation) { string text = ""; List fields = Class.GetFields().ToList(); List<(FieldInfo, List)> toolTips = GetToolTips(fields); List required = GetRequired(toolTips); if (!LinqExtensions.IsNullOrEmpty((IList)required)) { text = text + "\r\n " + new string(' ', Indentation * 4) + "\"required\": [\r\n " + new string(' ', Indentation * 4) + string.Join("," + Environment.NewLine + " " + new string(' ', Indentation * 4), required) + "\r\n " + new string(' ', Indentation * 4) + "],"; } text = text + "\r\n " + new string(' ', Indentation * 4) + "\"properties\": {"; List<(FieldInfo, List)> writable = GetWritable(toolTips); foreach (var (fieldInfo, tooltips) in writable) { if (fieldInfo.FieldType == typeof(string)) { text += HandleString(writable, fieldInfo, tooltips, Indentation, Class); } else if (fieldInfo.FieldType == typeof(int)) { text += HandleInt(writable, fieldInfo, tooltips, Indentation, Class); } else if (fieldInfo.FieldType == typeof(bool)) { text += HandleBoolean(writable, fieldInfo, tooltips, Indentation, Class); } else if (fieldInfo.FieldType == typeof(List)) { text += HandleStringArray(writable, fieldInfo, tooltips, Indentation, Class); } else if (fieldInfo.FieldType.IsGenericType && fieldInfo.FieldType.GetGenericTypeDefinition() == typeof(List<>)) { text += HandleObjectArray(writable, fieldInfo, tooltips, Indentation, Class); } else if (fieldInfo.FieldType.IsClass) { text += HandleObject(writable, fieldInfo, tooltips, Indentation, Class); } } return text + "\r\n " + new string(' ', Indentation * 4) + "},"; } static WriteSchema() { string dLLPath = FindFiles.DLLPath; char directorySeparatorChar = Path.DirectorySeparatorChar; SchemaFolder = dLLPath + directorySeparatorChar + DefineConfiguration.SchemaSavePath.Value; } } } namespace JSONLoader3.Peripheral.JSON_LINT { public class LintingTools { public static (List<(int depth, string propertyName, string propertyValue)> validatedJSON, bool check) LintAgainstSchema(string file, List JSONSchema, string LoaderName) { List list = LoadInJSONItem(file); foreach (string item3 in list) { int num = list.IndexOf(item3); if (num != list.Count - 1 && (list[num + 1].Trim().StartsWith("}") || list[num + 1].Trim().EndsWith("}")) && list[num].EndsWith(",")) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Trailing Comma Detected on the Last Line of the JSON."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "This error occurs when the last Key in the JSON has a comma at the end prior to closing a brace."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", $"To fix it just remove the comma at the end of line {num}."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); } } List<(int, string, string)> list2 = DisectedJSON(list); List<(int, string, string)> jSONSchemaProperties = DisectedJSON(JSONSchema); List requiredFromSchema = GetRequiredFromSchema(JSONSchema); List<(string, bool)> list3 = new List<(string, bool)>(); foreach (string item4 in requiredFromSchema) { list3.Add((item4, false)); } JSONLoader3.FormatLogger("Debug", "LintingTools", "Required Fields: " + string.Join(", ", requiredFromSchema)); foreach (var item5 in list2.Where<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.depth == 1)) { string traversalPath = GetTraversalPath(jSONSchemaProperties, item5, 2); if (traversalPath == string.Empty) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Something went wrong while doing PathTraversal for " + item5.Item2 + " the following should help identify what you did wrong."); if (GetTraversalPath(jSONSchemaProperties, (depth: item5.Item1, propertyName: StringUtilsExtensions.ToCamelCase(item5.Item2), propertyValue: item5.Item3), 2) != string.Empty) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The casing of " + item5.Item2 + " within " + Path.GetFileNameWithoutExtension(file) + " is not correct, it should be in camelCase."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Basically the Property needs to follow the correct convention which is first word in Lowercase, and the rest of the words first letters Capitalized."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "likeThis"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "In the JSON the KVP would look like: \"likeThis\": false"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return (validatedJSON: list2, check: false); } char directorySeparatorChar; if (!AllowExtraFieldsCheck(JSONSchema)) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The Property of " + item5.Item2 + " is not apart of the JSON Schema, please remove it from the JSON entitled " + Path.GetFileNameWithoutExtension(file) + "."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "If you want to stop seeing these when you make your jsons, just cross check the JSON against the Schema saving it."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Theres a nifty site called JSONEditor that you may find useful, theres a guide in the README."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Additionally you can cross-reference against the Property List we provide in our API's documentation and WIKI's."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); string[] obj = new string[8] { LoadSchema.SchemaFolder, null, null, null, null, null, null, null }; directorySeparatorChar = Path.DirectorySeparatorChar; obj[1] = directorySeparatorChar.ToString(); obj[2] = LoaderName; directorySeparatorChar = Path.DirectorySeparatorChar; obj[3] = directorySeparatorChar.ToString(); obj[4] = LoaderName; obj[5] = "_"; obj[6] = typeof(Class).Name; obj[7] = "_Schema.json"; JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "You can also find the full Schema here: " + Path.GetFullPath(string.Concat(obj))); return (validatedJSON: list2, check: false); } JSONLoader3.FormatLogger("Warning", "LintingTools", "The Property of " + item5.Item2 + " is not apart of the JSON Schema, please remove it from the JSON entitled " + Path.GetFileNameWithoutExtension(file) + "."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); string[] obj2 = new string[8] { LoadSchema.SchemaFolder, null, null, null, null, null, null, null }; directorySeparatorChar = Path.DirectorySeparatorChar; obj2[1] = directorySeparatorChar.ToString(); obj2[2] = LoaderName; directorySeparatorChar = Path.DirectorySeparatorChar; obj2[3] = directorySeparatorChar.ToString(); obj2[4] = LoaderName; obj2[5] = "_"; obj2[6] = typeof(Class).Name; obj2[7] = "_Schema.json"; JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "You can also find the full Schema here: " + Path.GetFullPath(string.Concat(obj2))); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "This is a warning because additionalProperties was enabled for this Object thus we're letting it slide."); } else { JSONLoader3.FormatLogger("Debug", "LintingTools", "Successfully Linted for Path: " + traversalPath); } if (requiredFromSchema.Contains(item5.Item2)) { JSONLoader3.FormatLogger("Debug", "LintingTools", "'" + item5.Item2 + "' is a required field."); for (int num2 = 0; num2 < list3.Count; num2++) { JSONLoader3.FormatLogger("Debug", "LintingTools", $"Required Tick [{num2}]: ({list3[num2].Item1}, {list3[num2].Item2})"); if (list3[num2].Item1 == item5.Item2) { list3[num2] = (item5.Item2, true); JSONLoader3.FormatLogger("Debug", "LintingTools", "Ticked '" + item5.Item2 + "' as checked."); break; } } } if (traversalPath != string.Empty) { List jSONSchemaProperty = GetJSONSchemaProperty(traversalPath, JSONSchema); string item = item5.Item2; string item2 = item5.Item3; string[] obj3 = new string[8] { LoadSchema.SchemaFolder, null, null, null, null, null, null, null }; char directorySeparatorChar = Path.DirectorySeparatorChar; obj3[1] = directorySeparatorChar.ToString(); obj3[2] = LoaderName; directorySeparatorChar = Path.DirectorySeparatorChar; obj3[3] = directorySeparatorChar.ToString(); obj3[4] = LoaderName; obj3[5] = "_"; obj3[6] = typeof(Class).Name; obj3[7] = "_Schema.json"; if (!ValidatePropertyAgainstSchema(item, item2, jSONSchemaProperty, file, Path.GetFullPath(string.Concat(obj3)))) { return (validatedJSON: list2, check: false); } } } JSONLoader3.FormatLogger("Debug", "LintingTools", "Final Required Ticks: " + string.Join(", ", list3.Select<(string, bool), string>(((string field, bool checkedField) x) => $"({x.field}, {x.checkedField})"))); foreach (var item6 in list3) { var (text, _) = item6; if (!item6.Item2) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Missing Required Field: " + text + " within " + Path.GetFileNameWithoutExtension(file) + "."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To Fix this, simply add the field mentioned in the error to the json with the appropriate value."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return (validatedJSON: list2, check: false); } } return (validatedJSON: list2, check: true); } public static string GetTraversalPath(List<(int depth, string propertyName, string propertyValue)> JSONSchemaProperties, (int depth, string propertyName, string propertyValue) JSON, int spelunkingDepth) { List list = new List(); int num = JSONSchemaProperties.FindIndex(((int depth, string propertyName, string propertyValue) x) => x.propertyName == JSON.propertyName && x.depth == JSON.depth * spelunkingDepth); if (num == -1) { return string.Empty; } list.Add(JSONSchemaProperties[num].propertyName); int item = JSONSchemaProperties[num].depth; for (int num2 = num - 1; num2 >= 0; num2--) { if (JSONSchemaProperties[num2].depth < item) { list.Insert(0, JSONSchemaProperties[num2].propertyName); item = JSONSchemaProperties[num2].depth; } } return string.Join("/", list); } public static List<(int depth, string propertyName, string propertyValue)> DisectedJSON(List JSONFile) { List<(int, string, string)> list = new List<(int, string, string)>(); int num = 0; foreach (string item2 in JSONFile) { int item = num; string text = item2.Trim(); foreach (char c in text) { if (c == '{' || c == '[') { num++; } else if (c == '}' || c == ']') { num--; } } if (!item2.Trim().StartsWith("{") && !item2.Trim().StartsWith("}") && !item2.Trim().StartsWith("[") && !item2.Trim().StartsWith("]") && item2.Trim().Contains(":")) { list.Add((item, item2.Trim().Substring(0, item2.Trim().IndexOf(":")).Trim() .Trim(new char[1] { '"' }), item2.Trim().Substring(item2.Trim().IndexOf(":") + 1).Trim() .TrimEnd(new char[1] { ',' }))); } } return list; } public static List LoadInJSONItem(string file) { FileStream stream = File.OpenRead(file); StreamReader streamReader = new StreamReader(stream); List list = new List(); while (streamReader.Peek() >= 0) { string item = streamReader.ReadLine(); list.Add(item); } streamReader.Dispose(); return list; } public static List GetJSONSchemaProperty(string propertyPath, List JSONSchema) { List list = (from x in propertyPath.Split(new char[1] { '/' }) where !string.IsNullOrWhiteSpace(x) select x).ToList(); List list2 = JSONSchema; foreach (string item in list) { list2 = DigThroughSchemaFindRelevant(item, list2); if (list2.Count == 0) { break; } } return list2; } public static List GetRequiredFromSchema(List JSONSchema) { List list = new List(); int num = -1; int num2 = -1; for (int i = 0; i < JSONSchema.Count; i++) { if (JSONSchema[i].Trim().StartsWith("\"required\": [")) { num = i + 1; break; } } if (num == -1) { return list; } for (int j = num; j < JSONSchema.Count; j++) { if (JSONSchema[j].Trim().TrimEnd(new char[1] { ',' }) == "]") { num2 = j; break; } } if (num2 == -1) { return list; } for (int k = num; k < num2; k++) { string text = JSONSchema[k].Trim().Trim('"', ','); if (!StringExtensions.IsNullOrWhitespace(text) && !list.Contains(text)) { list.Add(text); } } return list; } public static bool AllowExtraFieldsCheck(List JSONSchema) { bool result = true; foreach (string item in JSONSchema) { if (item.Contains("\"additionalProperties\": ")) { result = bool.Parse(item.Trim().Replace("\"additionalProperties\": ", "").Trim('"', ',')); break; } } return result; } internal static List DigThroughArrayFindRelevant(string jsonArray) { if (!jsonArray.Trim().StartsWith("[") || !jsonArray.Trim().EndsWith("]")) { return new List(); } string text = jsonArray.Trim().Substring(1, jsonArray.Trim().Length - 2).Trim(); List list = new List(); int num = 0; int num2 = 0; for (int i = 0; i < text.Length; i++) { if (text[i] == '{' || text[i] == '[') { num2++; } else if (text[i] == '}' || text[i] == ']') { num2--; } if (text[i] == ',' && num2 == 0) { list.Add(text.Substring(num, i - num).Trim()); num = i + 1; } } if (num < text.Length) { list.Add(text.Substring(num).Trim()); } return list; } internal static List DigThroughSchemaFindRelevant(string propertyToFind, List JSONSchema) { int num = -1; foreach (string item in JSONSchema) { if (item.Trim().StartsWith("\"" + propertyToFind + "\": {")) { num = JSONSchema.IndexOf(item); break; } } List list = new List(); if (num == -1) { JSONLoader3.FormatLogger("Warning", "LintingTools", "Could not find " + propertyToFind + " in Schema."); return list; } int num2 = 0; bool flag = false; for (int i = num; i < JSONSchema.Count; i++) { string text = JSONSchema[i]; list.Add(text); string text2 = text; for (int j = 0; j < text2.Length; j++) { switch (text2[j]) { case '{': num2++; flag = true; break; case '}': num2--; break; } } if (flag && num2 == 0) { break; } } return list; } internal static List<(int depth, string propertyName, string propertyValue)> GetObjectProperties(string jsonObject) { List list = new List { "{" }; list.AddRange(jsonObject.Trim().Split(new char[1] { '\n' })); list.Add("}"); List<(int, string, string)> list2 = DisectedJSON(list); if (list2.Count == 0) { return new List<(int, string, string)>(); } int objectDepth = list2[0].Item1; return list2.Where<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.depth == objectDepth).ToList(); } internal static List GetArrayItems(string jsonArray, string propertyName, string file) { if (jsonArray.Trim() != "[") { return DigThroughArrayFindRelevant(jsonArray); } List list = File.ReadAllLines(file).ToList(); int num = list.FindIndex((string x) => x.Trim().StartsWith("\"" + propertyName + "\"")); if (num == -1) { return new List(); } string text = list[num].Substring(list[num].IndexOf(":") + 1).Trim(); int num2 = 0; string text2 = text; for (int num3 = 0; num3 < text2.Length; num3++) { switch (text2[num3]) { case '[': num2++; break; case ']': num2--; break; } } while (num2 > 0 && num + 1 < list.Count) { num++; string text3 = list[num].Trim(); text = text + "\n" + text3; string text4 = text3; for (int num4 = 0; num4 < text4.Length; num4++) { switch (text4[num4]) { case '[': num2++; break; case ']': num2--; break; } } } return DigThroughArrayFindRelevant(text.TrimEnd(new char[1] { ',' })); } internal static List GetArrayItems(string jsonArray) { return DigThroughArrayFindRelevant(jsonArray); } public static bool ValidatePropertyAgainstSchema(string jsonPropertyName, string jsonPropertyValue, List PropertySchema, string file, string schemaFile) { string text = ""; string text2 = ""; bool flag = false; bool flag2 = false; List list = new List(PropertySchema); foreach (string item in PropertySchema) { if (PropertySchema.IndexOf(item) == 0) { list.RemoveAt(0); } if (item.Contains("\"type\": \"") && !flag) { text = item.Trim().Replace("\"type\": \"", "").Trim('"', ','); list.Remove(item); flag = true; } if (item.Contains("\"description\": \"") && !flag2) { text2 = item.Trim().Replace("\"description\": \"", "").Trim('"', ','); list.Remove(item); flag2 = true; } } JSONLoader3.FormatLogger("Summary", "LintingTools", "Property Description for " + jsonPropertyName + " for ease of access."); foreach (string item2 in text2.Split(new char[1] { '|' }).ToList()) { JSONLoader3.FormatLogger("Summary", "LintingTools", item2.Trim().Replace("\\\"", "\"")); } switch (text) { case "string": return ValidateString(jsonPropertyName, jsonPropertyValue, list, file, schemaFile); case "integer": return ValidateInteger(jsonPropertyName, jsonPropertyValue, list, file, schemaFile); case "boolean": return ValidateBoolean(jsonPropertyName, jsonPropertyValue, list, file, schemaFile); case "object": return ValidateObject(jsonPropertyName, jsonPropertyValue, list, file, schemaFile); case "array": return ValidateArray(jsonPropertyName, jsonPropertyValue, list, file, schemaFile); default: JSONLoader3.FormatLogger("Warning", "LintingTools", "Could not find " + text + " support for validating " + jsonPropertyName + " within this Item Type for validating against the Schema, notify a maintainer if this is not intentional."); return true; } } public static bool ValidateString(string jsonPropertyName, string jsonPropertyValue, List PropertySchema, string file, string schemaFile) { int num = -1; Regex regex = null; string text = ""; List list = new List(); for (int i = 0; i < PropertySchema.Count; i++) { string text2 = PropertySchema[i]; if (text2.Contains("\"minLength\": ")) { num = int.Parse(text2.Trim().Replace("\"minLength\": ", "").Trim('"', ',')); } if (text2.Contains("\"pattern\": \"")) { regex = new Regex(Regex.Unescape(text2.Trim().Replace("\"pattern\": \"", "").Trim('"', ','))); } if (text2.Contains("\"default\": \"")) { text = text2.Trim().Replace("\"default\": \"", "").Trim('"', ','); } if (!text2.Contains("\"enum\": [")) { continue; } int num2 = i + 1; for (int j = num2; j < PropertySchema.Count; j++) { string text3 = PropertySchema[j].Trim(); if (text3.TrimEnd(new char[1] { ',' }) == "]") { break; } string text4 = text3.Trim('"', ','); if (!StringExtensions.IsNullOrWhitespace(text4)) { list.Add(text4); } } break; } if (!jsonPropertyValue.StartsWith("\"") || !jsonPropertyValue.EndsWith("\"")) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Invalid String was Found. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this ensure the Value for this item is properly encases in Quotation marks."); return false; } if (num != -1 && jsonPropertyValue.Trim(new char[1] { '"' }).Length < num) { JSONLoader3.FormatLogger("ERROR", "LintingTools", $"The string is shorter than the Minimum Length ({num}) for {jsonPropertyName} according to the Schema for this Item. The JSON this error occured in: {Path.GetFileNameWithoutExtension(file)}"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", $"To fix this just simply extend the length of {jsonPropertyValue} above {num}."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (regex != null && !regex.IsMatch(jsonPropertyValue.Trim(new char[1] { '"' }))) { JSONLoader3.FormatLogger("ERROR", "LintingTools", $"The string value for {jsonPropertyName} is invalid based on the Regex specified by the Schema for this item ({regex}). The JSON this error occured in: {Path.GetFileNameWithoutExtension(file)}"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this copy the regex shown above and paste it into the expression box of https://regexr.com/."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Now take your value (" + jsonPropertyValue + ") and put it in the Text Box below it."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "The Regex will be described under tools, so now just edit your value for " + jsonPropertyName + " until it is valid."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Now just paste that value back into your JSON Key associated with " + jsonPropertyName + ", than your set for the next boot."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Keep in mind if it was an image, ensure the image matches that exact name. P.S. If your trying to route folders use '/' after the folders name to go in, and '../' to go in."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (StringExtensions.IsNullOrWhitespace(text) && StringExtensions.IsNullOrWhitespace(jsonPropertyValue.Trim(new char[1] { '"' }))) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The string is empty and there is no default value for " + jsonPropertyName + " either define it or remove it. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this simply as the error states remove the KVP for " + jsonPropertyName); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Alternatively define a value for " + jsonPropertyName + " you can toggle on Summary in The Config to show the Properties Description for further Information about it.."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } string valueToCheck = jsonPropertyValue.Trim().Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "LintingTools", "Enums found for " + jsonPropertyName + ": (" + string.Join(", ", list) + ")"); JSONLoader3.FormatLogger("Debug", "LintingTools", "Value being checked: (" + valueToCheck + ")"); bool flag = list.Any((string enumValue) => string.Equals(enumValue.Trim(), valueToCheck, StringComparison.Ordinal)); JSONLoader3.FormatLogger("Debug", "LintingTools", $"Enum validation result for ({valueToCheck}): {flag}"); if (list.Count > 0 && !flag) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The string does not match any of the required Enums for " + jsonPropertyName + " according to the Schema. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this just ensure the " + jsonPropertyName + " matches the actual Enums applicable for this field."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Look at the Description for " + jsonPropertyName + " for a list of possible values for this field."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } return true; } public static bool ValidateInteger(string jsonPropertyName, string jsonPropertyValue, List PropertySchema, string file, string schemaFile) { int num = -1; int num2 = -1; int num3 = -1; bool flag = false; bool flag2 = false; bool flag3 = false; foreach (string item in PropertySchema) { if (item.Contains("\"minimum\": ")) { num = int.Parse(item.Trim().Replace("\"minimum\": ", "").Trim('"', ',')); flag = true; } if (item.Contains("\"maximum\": ")) { num2 = int.Parse(item.Trim().Replace("\"maximum\": ", "").Trim('"', ',')); flag2 = true; } if (item.Contains("\"default\": ")) { num3 = int.Parse(item.Trim().Replace("\"default\": ", "").Trim('"', ',')); flag3 = true; } } if (jsonPropertyValue.StartsWith("\"") && jsonPropertyValue.EndsWith("\"")) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Invalid Int was Found. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this ensure the Value for this item is NOT encased in Quotation marks."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (StringExtensions.IsNullOrWhitespace(jsonPropertyValue) && !flag3) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The value is empty and there is no default value for " + jsonPropertyName + " either define it or remove it. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this simply as the error states remove the KVP for " + jsonPropertyName); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Alternatively define a value for " + jsonPropertyName + " you can toggle on Summary in The Config to show the Properties Description for further Information about it.."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (!int.TryParse(jsonPropertyValue, out var result)) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The Value passed in with " + jsonPropertyName + " is not a valid Integer. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "The value associated with " + jsonPropertyName + " did not parse correctly as an Integer, the value being (" + jsonPropertyValue + ")"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (result > num2 && flag2) { JSONLoader3.FormatLogger("ERROR", "LintingTools", $"The value of {jsonPropertyName} is Greater than the Maximum allowed by the Schema for this item, the maximum being {num2}. The JSON this error occured in: {Path.GetFileNameWithoutExtension(file)}"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", $"To fix this simply set the value of {jsonPropertyName} to a Integer less than {num2}."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (result < num && flag) { JSONLoader3.FormatLogger("ERROR", "LintingTools", $"The value of {jsonPropertyName} is Less than the Minimum allowed by the Schema for this item, the minimum being {num}. The JSON this error occured in: {Path.GetFileNameWithoutExtension(file)}"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", $"To fix this simply set the value of {jsonPropertyName} to a Integer greater than {num}."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } return true; } public static bool ValidateBoolean(string jsonPropertyName, string jsonPropertyValue, List PropertySchema, string file, string schemaFile) { bool flag = false; bool flag2 = false; foreach (string item in PropertySchema) { if (item.Contains("\"default\": ")) { flag = bool.Parse(item.Trim().Replace("\"default\": ", "").Trim('"', ',')); flag2 = true; } } if (jsonPropertyValue.StartsWith("\"") && jsonPropertyValue.EndsWith("\"")) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Invalid Boolean was Found. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this ensure the Value for this item is NOT encased in Quotation marks."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (StringExtensions.IsNullOrWhitespace(jsonPropertyValue) && !flag2) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The value is empty and there is no default value for " + jsonPropertyName + " either define it or remove it. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this simply as the error states remove the KVP for " + jsonPropertyName); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Alternatively define a value for " + jsonPropertyName + " you can toggle on Summary in The Config to show the Properties Description for further Information about it.."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (!bool.TryParse(jsonPropertyValue, out var _)) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The Value passed in with " + jsonPropertyName + " is not a valid Boolean. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "The value associated with " + jsonPropertyName + " did not parse correctly as an Boolean, the value being (" + jsonPropertyValue + ")"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (jsonPropertyValue != jsonPropertyValue.ToLower()) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The Value passed in with " + jsonPropertyName + " did not have the correct casing, the Value (" + jsonPropertyValue + ") must be all lowercase. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this just make sure the value associated with " + jsonPropertyName + " is in full lowercase."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } return true; } public static bool ValidateObject(string jsonPropertyName, string jsonPropertyValue, List PropertySchema, string file, string schemaFile) { List list = new List(); list.Add("{"); if (jsonPropertyValue.Trim().StartsWith("{")) { list.AddRange(jsonPropertyValue.Trim().Split(new char[1] { '\n' })); } else { list.Add("\"" + jsonPropertyName + "\": " + jsonPropertyValue); } list.Add("}"); List<(int, string, string)> list2 = DisectedJSON(list); if (list2.Count == 0) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Could not dissect object for " + jsonPropertyName + ". The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); return false; } int item = list2[0].Item1; if (!jsonPropertyValue.Trim().StartsWith("{")) { list2 = list2.Where<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName != jsonPropertyName).ToList(); } List<(int, string, string)> list3 = DisectedJSON(PropertySchema); List requiredFromSchema = GetRequiredFromSchema(PropertySchema); List<(string, bool)> list4 = new List<(string, bool)>(); foreach (string item3 in requiredFromSchema) { list4.Add((item3, false)); } JSONLoader3.FormatLogger("Debug", "LintingTools", "Required Fields: " + string.Join(", ", requiredFromSchema)); foreach (var item4 in list2) { JSONLoader3.FormatLogger("Debug", "LintingTools", $"Object Traversal: [{item4.Item2}] JSON Depth [{item4.Item1}]"); JSONLoader3.FormatLogger("Debug", "LintingTools", "Object Schema: " + string.Join(", ", list3.Select<(int, string, string), string>(((int depth, string propertyName, string propertyValue) x) => $"[{x.depth}] {x.propertyName}"))); int item2 = item4.Item1 - item + 1; string traversalPath = GetTraversalPath(list3, (depth: item2, propertyName: item4.Item2, propertyValue: item4.Item3), 2); if (traversalPath == string.Empty) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Something went wrong while doing PathTraversal for " + item4.Item2 + " the following should help identify what you did wrong."); if (GetTraversalPath(list3, (depth: item2, propertyName: StringUtilsExtensions.ToCamelCase(item4.Item2), propertyValue: item4.Item3), 2) != string.Empty) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The casing of " + item4.Item2 + " within " + Path.GetFileNameWithoutExtension(file) + " is not correct, it should be in camelCase."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Basically the Property needs to follow the correct convention which is first word in Lowercase, and the rest of the words first letters Capitalized."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "likeThis"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "In the JSON the KVP would look like: \"likeThis\": false"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } if (!AllowExtraFieldsCheck(PropertySchema)) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "The Property of " + item4.Item2 + " is not apart of the JSON Schema, please remove it from the JSON entitled " + Path.GetFileNameWithoutExtension(file) + "."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "If you want to stop seeing these when you make your jsons, just cross check the JSON against the Schema saving it."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Theres a nifty site called JSONEditor that you may find useful, theres a guide in the README."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Additionally you can cross-reference against the Property List we provide in our API's documentation and WIKI's."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "You can also find the full Schema here: " + schemaFile); } else { JSONLoader3.FormatLogger("Warning", "LintingTools", "The Property of " + item4.Item2 + " is not apart of the JSON Schema, please remove it from the JSON entitled " + Path.GetFileNameWithoutExtension(file) + "."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "You can also find the full Schema here: " + schemaFile); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "This is a warning because additionalProperties was enabled for this Object thus we're letting it slide."); } } else { JSONLoader3.FormatLogger("Debug", "LintingTools", "Successfully Linted for Path: " + traversalPath); } if (requiredFromSchema.Contains(item4.Item2)) { JSONLoader3.FormatLogger("Debug", "LintingTools", "'" + item4.Item2 + "' is a required field."); for (int num = 0; num < list4.Count; num++) { JSONLoader3.FormatLogger("Debug", "LintingTools", $"Required Tick [{num}]: ({list4[num].Item1}, {list4[num].Item2})"); if (list4[num].Item1 == item4.Item2) { list4[num] = (item4.Item2, true); JSONLoader3.FormatLogger("Debug", "LintingTools", "Ticked '" + item4.Item2 + "' as checked."); break; } } } if (traversalPath != string.Empty) { List jSONSchemaProperty = GetJSONSchemaProperty(traversalPath, PropertySchema); if (!ValidatePropertyAgainstSchema(item4.Item2, item4.Item3, jSONSchemaProperty, file, schemaFile)) { return false; } } } JSONLoader3.FormatLogger("Debug", "LintingTools", "Final Required Ticks: " + string.Join(", ", list4.Select<(string, bool), string>(((string field, bool checkedField) x) => $"({x.field}, {x.checkedField})"))); foreach (var item5 in list4) { var (text, _) = item5; if (!item5.Item2) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Missing Required Field: " + text + " within " + Path.GetFileNameWithoutExtension(file) + "."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To Fix this, simply add the field mentioned in the error to the json with the appropriate value."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } } return true; } public static bool ValidateArray(string jsonPropertyName, string jsonPropertyValue, List PropertySchema, string file, string schemaFile) { List arrayItems = GetArrayItems(jsonPropertyValue, jsonPropertyName, file); if (arrayItems.Count == 0) { JSONLoader3.FormatLogger("Warning", "LintingTools", "The Array is empty for " + jsonPropertyName + " either define it or remove it. The JSON this warming occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this simply as the error states remove the KVP for " + jsonPropertyName); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Alternatively define a value for " + jsonPropertyName + " you can toggle on Summary in The Config to show the Properties Description for further Information about it.."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "This is a warning because we have never been strict about this, but if you want to stop seeing this warning do the above."); return true; } bool flag = false; string text = ""; foreach (string item in PropertySchema) { if (item.Contains("\"uniqueItems\": ")) { flag = bool.Parse(item.Trim().Replace("\"uniqueItems\": ", "").Trim('"', ',')); } } if (flag && arrayItems.Distinct().Count() != arrayItems.Count) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "There is duplicated Array Items in the Array " + jsonPropertyName + ", according to the Schema for this Item, all Array Items must be Unique for " + jsonPropertyName + ". The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "To fix this error just ensure all Items of the Array are Unique, e.g. No Repeats within it."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Sadly as it broke here, I'm going to have to call a break, meaning we are going to stop proccessing this item and move on to the next one."); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Hopefully you'll have it fixed for next load up!!"); JSONLoader3.FormatLogger("AdditionalInformation", "LintingTools", "Here's the full path to the file the issue takes root in: " + file); return false; } List list = DigThroughSchemaFindRelevant("items", PropertySchema); if (list.Count == 0) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Array " + jsonPropertyName + " has no item schema defined. The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); JSONLoader3.FormatLogger("Warning", "LintingTools", "Could not find any Schema for validating the Items of the Array " + jsonPropertyName + ", notify a maintainer if you ever receive this, with a copy of your JSON file."); return false; } foreach (string item2 in list) { if (item2.Contains("\"type\": \"")) { text = item2.Trim().Replace("\"type\": \"", "").Trim('"', ','); break; } } foreach (string item3 in arrayItems) { bool flag2 = false; if (text == "object") { flag2 = ValidateObject(jsonPropertyName, item3, list, file, schemaFile); } else { List list2 = new List(); list2.Add("{"); list2.Add("\"" + jsonPropertyName + "\": " + item3); list2.Add("}"); List<(int, string, string)> list3 = DisectedJSON(list2); if (list3.Count == 0) { JSONLoader3.FormatLogger("ERROR", "LintingTools", "Could not dissect array item for " + jsonPropertyName + ". The JSON this error occured in: " + Path.GetFileNameWithoutExtension(file)); return false; } switch (text) { case "string": flag2 = ValidateString(list3[0].Item2, list3[0].Item3, list, file, schemaFile); break; case "integer": flag2 = ValidateInteger(list3[0].Item2, list3[0].Item3, list, file, schemaFile); break; case "boolean": flag2 = ValidateBoolean(list3[0].Item2, list3[0].Item3, list, file, schemaFile); break; case "array": flag2 = ValidateArray(list3[0].Item2, list3[0].Item3, list, file, schemaFile); break; default: JSONLoader3.FormatLogger("Warning", "LintingTools", "Could not find " + text + " support for validating " + jsonPropertyName + " within this Item Type for validating against the Schema, notify a maintainer if this is not intentional."); flag2 = true; break; } } if (!flag2) { return false; } } return true; } } } namespace JSONLoader3.Peripheral.ImageHandling { public class ScanImages { public static Sprite ParseImage(string plugin, string imagePath) { if (imagePath.StartsWith("data:image/png;base64,") || imagePath.StartsWith("base64:")) { return GetTextureFromBase64(imagePath); } if (!imagePath.Contains("/")) { return GetSpriteFromFileName(imagePath, plugin); } return GetTextureFromPluginAndPath(plugin, imagePath); } private static Texture2D GetTextureFromString(string path) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown if (path.StartsWith("data:image/png;base64,")) { try { string s = path.Substring("data:image/png;base64,".Length); byte[] array = Convert.FromBase64String(s); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)0; ImageConversion.LoadImage(val, array); return val; } catch (Exception ex) { JSONLoader3.FormatLogger("Error", "ScanImages", "Failed to convert base64 to texture: " + path); JSONLoader3.FormatLogger("Debug", "ScanImages", "Printing Message of Exception and Source"); JSONLoader3.FormatLogger("Debug", "ScanImages", ex.Message + " " + ex.Source); JSONLoader3.FormatLogger("Debug", "ScanImages", "Printing Stack Trace"); JSONLoader3.FormatLogger("Debug", "ScanImages", ex.StackTrace); } } if (path.StartsWith("base64:")) { try { string s2 = path.Substring("base64:".Length); byte[] array2 = Convert.FromBase64String(s2); Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false); ((Texture)val2).filterMode = (FilterMode)0; ImageConversion.LoadImage(val2, array2); return val2; } catch (Exception ex2) { JSONLoader3.FormatLogger("Error", "ScanImages", "Failed to convert base64 to texture: " + path); JSONLoader3.FormatLogger("Debug", "ScanImages", "Printing Message of Exception and Source"); JSONLoader3.FormatLogger("Debug", "ScanImages", ex2.Message + " " + ex2.Source); JSONLoader3.FormatLogger("Debug", "ScanImages", "Printing Stack Trace"); JSONLoader3.FormatLogger("Debug", "ScanImages", ex2.StackTrace); } } return TextureHelper.GetImageAsTexture(path, (FilterMode)0); } private static Sprite GetTextureFromBase64(string texture) { if (!string.IsNullOrEmpty(texture)) { Texture2D textureFromString = GetTextureFromString(texture); if ((Object)(object)textureFromString != (Object)null) { return TextureHelper.ConvertTexture(textureFromString, (Vector2?)null); } } return null; } private static Sprite GetTextureFromPluginAndPath(string plugin, string filePath) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) string fullPath = Path.GetFullPath(Path.Combine(plugin, filePath.Replace('/', Path.DirectorySeparatorChar))); if (!File.Exists(fullPath)) { fullPath = Path.GetFullPath(Path.Combine(plugin, "plugins", filePath.Replace('/', Path.DirectorySeparatorChar))); if (!File.Exists(fullPath)) { JSONLoader3.FormatLogger("Error", "ScanImages", "File not found at path: " + filePath + " when appended onto the Plugins Path."); JSONLoader3.FormatLogger("AdditionalInformation", "ScanImages", "We tried the following 2 paths: "); JSONLoader3.FormatLogger("AdditionalInformation", "ScanImages", Path.GetFullPath(Path.Combine(plugin, filePath.Replace('/', Path.DirectorySeparatorChar)))); JSONLoader3.FormatLogger("AdditionalInformation", "ScanImages", Path.GetFullPath(Path.Combine(plugin, "plugins", filePath.Replace('/', Path.DirectorySeparatorChar)))); JSONLoader3.FormatLogger("AdditionalInformation", "ScanImages", "To resolve this, just make sure the Path leads to where your asset is located, we don't recursively scan in this case."); Texture2D val = new Texture2D(114, 94); return Sprite.Create(val, new Rect(0f, 0f, 114f, 94f), new Vector2(0.5f, 0.5f)); } } return GetCustomImage(Path.GetFileNameWithoutExtension(filePath), Path.GetDirectoryName(fullPath)); } public static Sprite GetSpriteFromFileName(string fileName, string pluginPath) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) List list = Directory.GetFiles(pluginPath, "*", SearchOption.AllDirectories).ToList(); foreach (string item in list) { if (item.EndsWith(".png") && Path.GetFileName(item) == fileName) { return GetCustomImage(item.Replace(".png", ""), pluginPath); } } Texture2D val = new Texture2D(114, 94); return Sprite.Create(val, new Rect(0f, 0f, 114f, 94f), new Vector2(0.5f, 0.5f)); } private static Texture2D LoadCustomPNG(string fileName, string imagePath) { return LoadCustomTexture(fileName, imagePath); } private static Texture2D LoadCustomTexture(string fileName, string imagePath) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown string text = Path.Combine(imagePath, fileName + ".png"); if (File.Exists(text)) { byte[] array = File.ReadAllBytes(text); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, array); return val; } JSONLoader3.FormatLogger("Error", "ScanImages", "Texture not found at path: " + text); return null; } private static Sprite GetCustomImage(string fileName, string imagePath) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Texture2D val = LoadCustomPNG(fileName, imagePath); if ((Object)(object)val != (Object)null) { Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((Object)val2).name = fileName; return val2; } JSONLoader3.FormatLogger("Error", "ScanImages", "Sprite creation failed for: " + fileName + " at path: " + imagePath); return null; } } } namespace JSONLoader3.Peripheral.FILE_Loader { public class FindFiles { private static Assembly assembly = Assembly.GetExecutingAssembly(); internal static string DLLPath = Path.GetDirectoryName(assembly.Location); public static void FindFilesToLoad() { string text = FindElementInPath(DLLPath, "BepInEx"); if (text != null) { char directorySeparatorChar = Path.DirectorySeparatorChar; string path = text + directorySeparatorChar + "plugins"; if (Directory.Exists(path)) { JSONLoader3.FormatLogger("Information", "FindFiles", "We are now attempting to scan for files in which JSONLoader3 or CSVLoader will need to load. If you have verbose lFogging on we'll show all the paths as it happens."); List list = Directory.GetDirectories(path).ToList(); { foreach (string item in list) { if (DefineConfiguration.toggleRecursiveOnPlugin.Value) { List list2 = Directory.GetFiles(item, "*", SearchOption.AllDirectories).ToList(); foreach (string item2 in list2) { HandleJSONFile(item2, item); } } else { JSONLoader3.FormatLogger("Debug", "FindFiles", "Checking Plugin: " + item + " for loadable JSON files."); string[] array = DefineConfiguration.JSONLoadingPaths.Value.Split(new char[1] { ',' }); foreach (string text2 in array) { directorySeparatorChar = Path.DirectorySeparatorChar; if (!Directory.Exists(item + directorySeparatorChar + text2.Trim().Replace('/', Path.DirectorySeparatorChar))) { continue; } directorySeparatorChar = Path.DirectorySeparatorChar; string path2 = item + directorySeparatorChar + text2.Trim().Replace('/', Path.DirectorySeparatorChar); List list3 = Directory.GetFiles(path2, "*", SearchOption.AllDirectories).ToList(); foreach (string item3 in list3) { HandleJSONFile(item3, item); } } } if (DefineConfiguration.toggleRecursiveOnPlugin.Value) { List list4 = Directory.GetFiles(item, "*", SearchOption.AllDirectories).ToList(); foreach (string item4 in list4) { HandleCSVFile(item4, item); } continue; } JSONLoader3.FormatLogger("Debug", "FindFiles", "Checking Plugin: " + item + " for loadable CSV files."); string[] array2 = DefineConfiguration.CSVLoadingPaths.Value.Split(new char[1] { ',' }); foreach (string text3 in array2) { directorySeparatorChar = Path.DirectorySeparatorChar; if (!Directory.Exists(item + directorySeparatorChar + text3.Trim().Replace('/', Path.DirectorySeparatorChar))) { continue; } directorySeparatorChar = Path.DirectorySeparatorChar; string path3 = item + directorySeparatorChar + text3.Trim().Replace('/', Path.DirectorySeparatorChar); List list5 = Directory.GetFiles(path3, "*", SearchOption.AllDirectories).ToList(); foreach (string item5 in list5) { HandleCSVFile(item5, item); } } } return; } } JSONLoader3.FormatLogger("Error", "FindFiles", "Your install is missing a 'plugins' Folder, please ensure there is one if you are seeing this error arise and that it is lowercase."); JSONLoader3.FormatLogger("ExtendedInformation", "FindFiles", "This error is mainly because for whatever reason you either don't have a 'plugins' folder, or your 'plugins' folder was capitalized wrong."); } else { JSONLoader3.FormatLogger("Error", "FindFiles", "Not sure how this is even running right now, but this error is because JSONLoader was not found within the BepInEx path."); JSONLoader3.FormatLogger("ExtendedInformation", "FindFiles", "This error occurs primarily when this Plugin was not placed under the Plugins Folder, or if the Plugins folder could not be found. We expect Lowercase for the Path."); } } internal static void HandleJSONFile(string JSONFile, string plugin) { if ((!JSONFile.EndsWith(".jldr", StringComparison.OrdinalIgnoreCase) && !JSONFile.EndsWith(".jldr2", StringComparison.OrdinalIgnoreCase) && !JSONFile.EndsWith(".jldr3", StringComparison.OrdinalIgnoreCase)) || JSONFile.EndsWith("_example.jldr", StringComparison.OrdinalIgnoreCase) || JSONFile.EndsWith("_example.jldr2", StringComparison.OrdinalIgnoreCase) || JSONFile.EndsWith("_example.jldr3", StringComparison.OrdinalIgnoreCase)) { return; } if (Directory.Exists(JSONFile)) { List list = Directory.GetFiles(JSONFile).ToList(); foreach (string item in list) { HandleJSONFile(item, plugin); } } if (JSONFile.EndsWith(".jldr", StringComparison.OrdinalIgnoreCase)) { LoadFiles.JLDRFiles.Add((plugin, JSONFile)); } else if (JSONFile.EndsWith(".jldr2", StringComparison.OrdinalIgnoreCase)) { LoadFiles.JLDR2Files.Add((plugin, JSONFile)); } else if (JSONFile.EndsWith(".jldr3", StringComparison.OrdinalIgnoreCase)) { LoadFiles.JLDR3Files.Add((plugin, JSONFile)); } JSONLoader3.FormatLogger("Debug", "FindFiles", "Found File: " + JSONFile + " to load."); } internal static void HandleCSVFile(string CSVFile, string plugin) { if (!CSVFile.EndsWith(".csv", StringComparison.OrdinalIgnoreCase) || CSVFile.EndsWith("_example.csv", StringComparison.OrdinalIgnoreCase)) { return; } if (Directory.Exists(CSVFile)) { List list = Directory.GetFiles(CSVFile).ToList(); foreach (string item in list) { HandleCSVFile(item, plugin); } } if (CSVFile.EndsWith(".csv", StringComparison.OrdinalIgnoreCase)) { LoadFiles.CSVFiles.Add((plugin, CSVFile)); } JSONLoader3.FormatLogger("Debug", "FindFiles", "Found File: " + CSVFile + " to load."); } internal static string FindElementInPath(string fullPath, string toFind) { string text = fullPath; while (!string.IsNullOrEmpty(text)) { string fileName = Path.GetFileName(text); if (string.Equals(fileName, toFind, StringComparison.OrdinalIgnoreCase)) { return text; } text = Path.GetDirectoryName(text); } return null; } } public class LoadFiles { internal static List<(string plugin, string file)> JLDRFiles = new List<(string, string)>(); internal static List<(string plugin, string file)> JLDR2Files = new List<(string, string)>(); internal static List<(string plugin, string file)> JLDR3Files = new List<(string, string)>(); internal static List<(string plugin, string file)> CSVFiles = new List<(string, string)>(); public static void LoadFoundFiles() { JSONLoader3.FormatLogger("Info", "LoadFiles", "Loading XML Documentation File!!"); ReadDocumentationFile.FetchDocFile(); JSONLoader3.FormatLogger("Info", "LoadFiles", "Loading JLDR Files!!"); foreach (var (item, item2) in JLDRFiles) { CardUtils.CardsToLoad.Add((item, item2)); } CardUtils.HandleCards(); JSONLoader3.FormatLogger("Info", "LoadFiles", "Loading JLDR2 Files!!"); foreach (var (text, text2) in JLDR2Files) { } JSONLoader3.FormatLogger("Info", "LoadFiles", "Loading JLDR3 Files!!"); foreach (var (text3, text4) in JLDR3Files) { } JSONLoader3.FormatLogger("Info", "LoadFiles", "Loading CSV Files!!"); foreach (var (text5, text6) in CSVFiles) { } } } } namespace JSONLoader3.Cores.JSONLoaderV1Support.Utilities { public class CardUtils { internal static List<(string pluginName, string file)> CardsToLoad = new List<(string, string)>(); internal static List allJLDRCards = new List(); public static ReadOnlyCollection allJLDRCardsPublic => allJLDRCards.AsReadOnly(); public static void HandleCards() { if (CardsToLoad.Count == 0) { return; } JSONLoader3.FormatLogger("Debug", "CardUtils", "Writing JSONLoaderV1's " + typeof(Card).Name + "'s Schema so that we can Lint against it."); WriteSchema.WriteJSONSchema("JSONLoaderV1"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Loading JSONLoaderV1's " + typeof(Card).Name + "'s Schema so that we can Lint against it."); List jSONSchema = LoadSchema.FindAndLoadSchema("JSONLoaderV1"); foreach (var (pluginName, text) in CardsToLoad) { JSONLoader3.FormatLogger("Debug", "CardUtils", "Linting " + text + " against Schema."); (List<(int depth, string propertyName, string propertyValue)> validatedJSON, bool check) tuple2 = LintingTools.LintAgainstSchema(text, jSONSchema, "JSONLoaderV1"); var (jSONCard, _) = tuple2; if (tuple2.check) { JSONLoader3.FormatLogger("Debug", "CardUtils", "Linting " + text + " against Schema was Successful, attempting to Parse into a JSONLoaderV1's " + typeof(Card).Name + "."); Parse(jSONCard, text, pluginName); } } } public static void Parse(List<(int depth, string propertyName, string propertyValue)> JSONCard, string file, string pluginName) { List list = new List(); string text = string.Empty; string text2 = string.Empty; string text3 = string.Empty; List list2 = new List(); string text4 = string.Empty; string text5 = string.Empty; int num = 0; int num2 = 0; bool flag = false; int num3 = 0; int num4 = 0; int num5 = 0; List list3 = new List(); string text6 = string.Empty; List list4 = new List(); List list5 = new List(); List list6 = new List(); List list7 = new List(); List list8 = new List(); List list9 = new List(); global::JSONLoader3.Cores.JSONLoaderV1Support.Objects.EvolveData evolveData = null; string text7 = string.Empty; global::JSONLoader3.Cores.JSONLoaderV1Support.Objects.TailData tailData = null; global::JSONLoader3.Cores.JSONLoaderV1Support.Objects.IceCubeData iceCubeData = null; bool flag2 = false; bool flag3 = false; List list10 = new List(); string text8 = string.Empty; string text9 = string.Empty; string text10 = string.Empty; string text11 = string.Empty; string text12 = string.Empty; List list11 = new List(); foreach (var (num6, text13, text14) in JSONCard) { JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({text14}), depth of ({num6}) while parsing {typeof(Card).Name}."); if (text13 == "fieldsToEdit" && num6 == 1) { list = (from x in LintingTools.GetArrayItems(text14, text13, file) select x.Trim().Trim(new char[1] { '"' }) into x where !string.IsNullOrEmpty(x) select x).ToList(); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "name" && num6 == 1) { text = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "displayedName" && num6 == 1) { text2 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text2 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "description" && num6 == 1) { text3 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text3 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "metaCategories" && num6 == 1) { list2 = (from x in LintingTools.GetArrayItems(text14, text13, file) select x.Trim().Trim(new char[1] { '"' }) into x where !string.IsNullOrEmpty(x) select x).ToList(); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list2) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "cardComplexity" && num6 == 1) { text4 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text4 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "temple" && num6 == 1) { text5 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text5 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "baseAttack" && num6 == 1) { num = int.Parse(text14); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({num}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "baseHealth" && num6 == 1) { num2 = int.Parse(text14); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({num2}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "hideAttackAndHealth" && num6 == 1) { flag = bool.Parse(text14); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({flag}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "bloodCost" && num6 == 1) { num3 = int.Parse(text14); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({num3}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "bonesCost" && num6 == 1) { num4 = int.Parse(text14); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({num4}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "energyCost" && num6 == 1) { num5 = int.Parse(text14); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({num5}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "gemColors" && num6 == 1) { list3 = (from x in LintingTools.GetArrayItems(text14, text13, file) select x.Trim().Trim(new char[1] { '"' }) into x where !string.IsNullOrEmpty(x) select x).ToList(); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list3) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "specialStatIcon" && num6 == 1) { text6 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text6 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "tribes" && num6 == 1) { list4 = (from x in LintingTools.GetArrayItems(text14, text13, file) select x.Trim().Trim(new char[1] { '"' }) into x where !string.IsNullOrEmpty(x) select x).ToList(); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list4) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "traits" && num6 == 1) { list5 = (from x in LintingTools.GetArrayItems(text14, text13, file) select x.Trim().Trim(new char[1] { '"' }) into x where !string.IsNullOrEmpty(x) select x).ToList(); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list5) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "specialAbilities" && num6 == 1) { list6 = (from x in LintingTools.GetArrayItems(text14, text13, file) select x.Trim().Trim(new char[1] { '"' }) into x where !string.IsNullOrEmpty(x) select x).ToList(); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list6) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "abilities" && num6 == 1) { list7 = (from x in LintingTools.GetArrayItems(text14, text13, file) select x.Trim().Trim(new char[1] { '"' }) into x where !string.IsNullOrEmpty(x) select x).ToList(); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list7) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "customAbilities" && num6 == 1) { List arrayItems = LintingTools.GetArrayItems(text14, text13, file); foreach (string item2 in arrayItems) { List<(int, string, string)> objectProperties = LintingTools.GetObjectProperties(item2); JSONLoader3.FormatLogger("Debug", "CardUtils", "customAbilityObject = (" + item2 + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "ability properties = (" + string.Join(", ", objectProperties.Select<(int, string, string), string>(((int depth, string propertyName, string propertyValue) x) => "[" + x.propertyName + "] = [" + x.propertyValue + "]")) + ")"); string name = objectProperties.First<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName == "name").Item3.Trim(new char[1] { '"' }); string gUID = objectProperties.First<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName == "GUID").Item3.Trim(new char[1] { '"' }); list8.Add(new global::JSONLoader3.Cores.JSONLoaderV1Support.Objects.AbilityData(name, gUID)); } JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list8) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "customSpecialAbilities" && num6 == 1) { List arrayItems2 = LintingTools.GetArrayItems(text14, text13, file); foreach (string item3 in arrayItems2) { List<(int, string, string)> objectProperties2 = LintingTools.GetObjectProperties(item3); string name2 = objectProperties2.First<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName == "name").Item3.Trim(new char[1] { '"' }); string gUID2 = objectProperties2.First<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName == "GUID").Item3.Trim(new char[1] { '"' }); list9.Add(new global::JSONLoader3.Cores.JSONLoaderV1Support.Objects.SpecialAbilityData(name2, gUID2)); } JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list9) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "evolution" && num6 == 1) { List<(int, string, string)> objectProperties3 = LintingTools.GetObjectProperties(text14); string name3 = objectProperties3.First<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName == "evolutionName").Item3.Trim(new char[1] { '"' }); int turnsToEvolve = int.Parse(objectProperties3.First<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName == "turnsToEvolve").Item3.Trim(new char[1] { '"' })); evolveData = new global::JSONLoader3.Cores.JSONLoaderV1Support.Objects.EvolveData(name3, turnsToEvolve); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({evolveData}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "defaultEvolutionName" && num6 == 1) { text7 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text7 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "tail" && num6 == 1) { List<(int, string, string)> objectProperties4 = LintingTools.GetObjectProperties(text14); string name4 = objectProperties4.First<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName == "tailName").Item3.Trim(new char[1] { '"' }); string tailLostPortrait = objectProperties4.First<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName == "tailLostPortrait").Item3.Trim(new char[1] { '"' }); tailData = new global::JSONLoader3.Cores.JSONLoaderV1Support.Objects.TailData(name4, tailLostPortrait); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({tailData}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "iceCube" && num6 == 1) { List<(int, string, string)> objectProperties5 = LintingTools.GetObjectProperties(text14); string creatureWithin = objectProperties5.First<(int, string, string)>(((int depth, string propertyName, string propertyValue) x) => x.propertyName == "creatureWithin").Item3.Trim(new char[1] { '"' }); iceCubeData = new global::JSONLoader3.Cores.JSONLoaderV1Support.Objects.IceCubeData(creatureWithin); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({iceCubeData}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "flipPortraitForStrafe" && num6 == 1) { flag2 = bool.Parse(text14); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({flag2}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "onePerDeck" && num6 == 1) { flag3 = bool.Parse(text14); JSONLoader3.FormatLogger("Debug", "CardUtils", $"Found {text13} with value of ({flag3}) successfully while parsing {typeof(Card).Name} from {Path.GetFileNameWithoutExtension(pluginName)} specifically {Path.GetFileNameWithoutExtension(file)}."); } if (text13 == "appearanceBehaviour" && num6 == 1) { list10 = (from x in LintingTools.GetArrayItems(text14, text13, file) select x.Trim().Trim(new char[1] { '"' }) into x where !string.IsNullOrEmpty(x) select x).ToList(); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list10) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "texture" && num6 == 1) { text8 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text8 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "altTexture" && num6 == 1) { text9 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text9 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "emissionTexture" && num6 == 1) { text10 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text10 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "titleGraphic" && num6 == 1) { text11 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text11 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "pixelTexture" && num6 == 1) { text12 = text14.Trim(new char[1] { '"' }); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + text12 + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } if (text13 == "decals" && num6 == 1) { list11 = (from x in LintingTools.GetArrayItems(text14, text13, file) select x.Trim().Trim(new char[1] { '"' }) into x where !string.IsNullOrEmpty(x) select x).ToList(); JSONLoader3.FormatLogger("Debug", "CardUtils", "Found " + text13 + " with value of (" + string.Join(", ", list11) + ") successfully while parsing " + typeof(Card).Name + " from " + Path.GetFileNameWithoutExtension(pluginName) + " specifically " + Path.GetFileNameWithoutExtension(file) + "."); } } CardObject cardObject = new CardObject(list, text, text2, text3, list2, text4, text5, num, num2, flag, num3, num4, num5, list3, text6, list4, list5, list6, list7, list8, list9, evolveData, text7, tailData, iceCubeData, flag2, flag3, list10, text8, text9, text10, text11, text12, list11, file, pluginName); CardInfo item = cardObject.ConvertCardObjectToCardInfo(); allJLDRCards.Add(item); } } } namespace JSONLoader3.Cores.JSONLoaderV1Support.Schemas { [Serializable] public class Card { [Tooltip("Items(True) | ItemType(string) | UniqueItems(true) | Enums(displayedName, description, metaCategories, cardComplexity, temple, baseAttack, baseHealth, hideAttackAndHealth, bloodCost, bonesCost, energyCost, gemColors, specialStatIcon, tribes, traits, specialAbilities, abilities, customAbilities, customSpecialAbilities, evolution, defaultEvolutionName, tail, iceCube, flipPortraitForStrafe, onePerDeck, appearanceBehavior, texture, altTexture, emissionTexture, titleGraphic, pixelTexture, decals)")] public List fieldsToEdit; [Tooltip("REQUIRED | MinimumLength(1) | Pattern(^[a-zA-Z\\d_]+$)")] public string name; public string displayedName; public string description; [Tooltip("Items(true) | ItemType(string) | Enums(ChoiceNode, TraderOffer, Part3Random, Rare, GBCPack, GBCPlayable, AscensionUnlock) | UniqueItems(true)")] public List metaCategories; [Tooltip("Default(Vanilla) | Enums(Vanilla, Simple, Intermediate, Advanced)")] public string cardComplexity; [Tooltip("Default(Nature) | Enums(Nature, Undead, Tech, Wizard)")] public string temple; [Tooltip("Default(0) | Minimum(0)")] public int baseAttack; [Tooltip("Default(1) | Minimum(1)")] public int baseHealth; [Tooltip("Default(false)")] public bool hideAttackAndHealth; [Tooltip("Default(0) | Minimum(0)")] public int bloodCost; [Tooltip("Default(0) | Minimum(0)")] public int bonesCost; [Tooltip("Default(0) | Minimum(0)")] public int energyCost; [Tooltip("Items(true) | ItemType(String) | Enums(Green, Orange, Blue) | UniqueItems(true)")] public List gemColors; [Tooltip("Enums(None, Ants, Bones, Mirror, Bell, GreenGems, CardsInHand, SacrificesThisTurn)")] public string specialStatIcon; [Tooltip("Items(true) | ItemType(String) | Enums(None, Squirrel, Bird, Canine, Hooved, Reptile, Insect) | UniqueItems(true)")] public List tribes; [Tooltip("Items(true) | ItemType(String) | Enums(None, EatsWarrens, FeedsStoat, LikesHoney, Wolf, Bear, Juvenile, ProtectsCub, Undead, Structure, Blind, Ant, Terrain, Pelt, Uncuttable, SatisfiesRingTrial, Giant, Gem, Fused, KillsSurvivors, Goat, DeathcardCreationNonOption, Lice) | UniqueItems(true)")] public List traits; [Tooltip("Items(true) | ItemType(String) | Enums(None, Cat, EMPTY3, EMPTY4, EMPTY5, EMPTY6, Ant, RandomCard, Lammergeier, TalkingCardChooser, PackMule, Mirror, BellProximity, CagedWolf, TrapSpawner, GiantCard, GiantMoon, GreenMage, JerseyDevil, Daus, BountyHunter, BrokenCoinLeft, BrokenCoinRight, CardsInHand, Ouroboros, Shapeshifter, SacrificesThisTurn, SpawnLice, GiantShip) | UniqueItems(true)")] public List specialAbilities; [Tooltip("Items(true) | ItemType(String) | Enums(None, DrawRabbits, BeesOnHit, Strafe, Deathtouch, Evolve, CreateDams, Tutor, WhackAMole, DrawCopy, TailOnHit, CorpseEater, QuadrupleBones, Submerge, DrawCopyOnDeath, Sharp, StrafePush, DrawAnt, GuardDog, Flying, Sacrificial, PreventAttack, TripleBlood, Reach, SplitStrike, TriStrike, IceCube, Sinkhole, BoneDigger, RandomConsumable, SteelTrap, RandomAbility, SquirrelOrbit, AllStrike, BuffNeighbours, Brittle, SkeletonStrafe, GainGemGreen, GainGemOrange, GainGemBlue, BuffGems, DropRubyOnDeath, GemsDraw, GemDependant, GainGemTriple, DrawNewHand, SquirrelStrafe, ConduitBuffAttack, ConduitFactory, ConduitHeal, ConduitNull, GainBattery, ExplodeOnDeath, Sniper, DeathShield, PermaDeath, LatchExplodeOnDeath, LatchBrittle, LatchDeathShield, FileSizeDamage, DeleteFile, Transformer, Sentry, ExplodeGems, ShieldGems, DrawVesselOnHit, ConduitEnergy, BombSpawner, DoubleDeath, ActivatedRandomPowerEnergy, ActivatedRandomPowerBone, ActivatedStatsUp, SwapStats, ActivatedDrawSkeleton, ActivatedDealDamage, CreateBells, BuffEnemy, ConduitSpawnGems, DrawRandomCardOnDeath, Loot, ActivatedSacrificeDrawCards, ActivatedStatsUpEnergy, ActivatedHeal, DebuffEnemy, CellBuffSelf, CellDrawRandomCardOnDeath, CellTriStrike, ActivatedEnergyToBones, MoveBeside, SubmergeSquid, BloodGuzzler, Haunter, ExplodingCorpse, Apparition, VirtualReality, EdaxioHead, EdaxioArms, EdaxioLegs, EdaxioTorso, CreateEgg, DoubleStrike, OpponentBones, StrafeSwap, Morsel, GainAttackOnKill, MadeOfStone, HydraEgg) | UniqueItems(true)")] public List abilities; [Tooltip("Items(true) | ItemType(Object) | AdditionalProperties(false) | UniqueItems(true)")] public List customAbilities; [Tooltip("Items(true) | ItemType(Object) | AdditionalProperties(false) | UniqueItems(true)")] public List customSpecialAbilities; [Tooltip("AdditionalProperties(false)")] public EvolveData evolution; public string defaultEvolutionName; [Tooltip("AdditionalProperties(false)")] public TailData tail; [Tooltip("AdditionalProperties(false)")] public IceCubeData iceCube; [Tooltip("Default(false)")] public bool flipPortraitForStrafe; [Tooltip("Default(false)")] public bool onePerDeck; [Tooltip("Items(true) | ItemType(String) | Enums(StaticGlitch, FullCardPortrait, TerrainBackground, RareCardColors, AddSnelkDecals, AnimatedPortrait, GoldEmission, RareCardBackground, AlternatingBloodDecal, TerrainLayout, DynamicPortrait, GiantAnimatedPortrait, HologramPortrait, SexyGoat, RedEmission, DefaultEmission, MoonParticleEffects) | UniqueItems(true)")] public List appearanceBehaviour; [Tooltip("Pattern(^(?:(?:\\.\\.\\/|[a-zA-Z\\d_\\s-]+\\/)*[a-zA-Z\\d_\\s-]+\\.png|data:image\\/png;base64,[A-Za-z0-9+/]+={0,2}|base64:[A-Za-z0-9+/]+={0,2})$)")] public string texture; [Tooltip("Pattern(^(?:(?:\\.\\.\\/|[a-zA-Z\\d_\\s-]+\\/)*[a-zA-Z\\d_\\s-]+\\.png|data:image\\/png;base64,[A-Za-z0-9+/]+={0,2}|base64:[A-Za-z0-9+/]+={0,2})$)")] public string altTexture; [Tooltip("Pattern(^(?:(?:\\.\\.\\/|[a-zA-Z\\d_\\s-]+\\/)*[a-zA-Z\\d_\\s-]+\\.png|data:image\\/png;base64,[A-Za-z0-9+/]+={0,2}|base64:[A-Za-z0-9+/]+={0,2})$)")] public string emissionTexture; [Tooltip("Pattern(^(?:(?:\\.\\.\\/|[a-zA-Z\\d_\\s-]+\\/)*[a-zA-Z\\d_\\s-]+\\.png|data:image\\/png;base64,[A-Za-z0-9+/]+={0,2}|base64:[A-Za-z0-9+/]+={0,2})$)")] public string titleGraphic; [Tooltip("Pattern(^(?:(?:\\.\\.\\/|[a-zA-Z\\d_\\s-]+\\/)*[a-zA-Z\\d_\\s-]+\\.png|data:image\\/png;base64,[A-Za-z0-9+/]+={0,2}|base64:[A-Za-z0-9+/]+={0,2})$)")] public string pixelTexture; [Tooltip("Items(True) | ItemType(string) | Pattern(^(?:(?:\\.\\.\\/|[a-zA-Z\\d_\\s-]+\\/)*[a-zA-Z\\d_\\s-]+\\.png|data:image\\/png;base64,[A-Za-z0-9+/]+={0,2}|base64:[A-Za-z0-9+/]+={0,2})$) | UniqueItems(true)")] public List decals; } [Serializable] public class AbilityData { [Tooltip("REQUIRED | MinimumLength(1) | Pattern(^[a-zA-Z\\d_\\s]+$)")] public string name; [Tooltip("REQUIRED | MinimumLength(1) | Pattern(^[a-zA-Z\\d_.]+$)")] public string GUID; } [Serializable] public class SpecialAbilityData { [Tooltip("REQUIRED | MinimumLength(1) | Pattern(^[a-zA-Z\\d_\\s]+$)")] public string name; [Tooltip("REQUIRED | MinimumLength(1) | Pattern(^[a-zA-Z\\d_.]+$)")] public string GUID; } [Serializable] public class EvolveData { [Tooltip("REQUIRED | Pattern(^[a-zA-Z\\d_]+$)")] public string name; [Tooltip("REQUIRED | Default(1) | Minimum(1) | Maximum(3)")] public int turnsToEvolve; } [Serializable] public class TailData { [Tooltip("REQUIRED | Pattern(^[a-zA-Z\\d_]+$)")] public string name; [Tooltip("Pattern(^(?:(?:\\.\\.\\/|[a-zA-Z\\d_\\s-]+\\/)*[a-zA-Z\\d_\\s-]+\\.png|data:image\\/png;base64,[A-Za-z0-9+/]+={0,2}|base64:[A-Za-z0-9+/]+={0,2})$)")] public string tailLostPortrait; } [Serializable] public class IceCubeData { [Tooltip("REQUIRED | Pattern(^[a-zA-Z\\d_]+$)")] public string creatureWithin; } } namespace JSONLoader3.Cores.JSONLoaderV1Support.Objects { public class CardObject { public List fieldsToEdit { get; set; } public string name { get; set; } public string displayedName { get; set; } public string description { get; set; } public List metaCategories { get; set; } public string cardComplexity { get; set; } public string temple { get; set; } public int baseAttack { get; set; } public int baseHealth { get; set; } public bool hideAttackAndHealth { get; set; } public int bloodCost { get; set; } public int bonesCost { get; set; } public int energyCost { get; set; } public List gemColors { get; set; } public string specialStatIcon { get; set; } public List tribes { get; set; } public List traits { get; set; } public List specialAbilities { get; set; } public List abilities { get; set; } public List customAbilities { get; set; } public List customSpecialAbilities { get; set; } public EvolveData evolution { get; set; } public string defaultEvolutionName { get; set; } public TailData tail { get; set; } public IceCubeData iceCube { get; set; } public bool flipPortraitForStrafe { get; set; } public bool onePerDeck { get; set; } public List appearanceBehaviour { get; set; } public string texture { get; set; } public string altTexture { get; set; } public string emissionTexture { get; set; } public string titleGraphic { get; set; } public string pixelTexture { get; set; } public List decals { get; set; } internal string file { get; set; } internal string pluginName { get; set; } public CardObject(List fieldsToEdit, string name, string displayedName = "", string description = "", List metaCategories = null, string cardComplexity = "Vanilla", string temple = "Nature", int baseAttack = 0, int baseHealth = 1, bool hideAttackAndHealth = false, int bloodCost = 0, int bonesCost = 0, int energyCost = 0, List gemColors = null, string specialStatIcon = "", List tribes = null, List traits = null, List specialAbilities = null, List abilities = null, List customAbilities = null, List customSpecialAbilities = null, EvolveData evolution = null, string defaultEvolutionName = "", TailData tail = null, IceCubeData iceCube = null, bool flipPortraitForStrafe = false, bool onePerDeck = false, List appearanceBehaviour = null, string texture = "", string altTexture = "", string emissionTexture = "", string titleGraphic = "", string pixelTexture = "", List decals = null, string file = null, string pluginName = null) { this.fieldsToEdit = fieldsToEdit; this.name = "Chaosyr.MADH95.Inscryption.JSON.CSVLoader_" + name; this.displayedName = displayedName; this.description = description; this.metaCategories = metaCategories; this.cardComplexity = cardComplexity; this.temple = temple; this.baseAttack = baseAttack; this.baseHealth = baseHealth; this.hideAttackAndHealth = hideAttackAndHealth; this.bloodCost = bloodCost; this.bonesCost = bonesCost; this.energyCost = energyCost; this.gemColors = gemColors; this.specialStatIcon = specialStatIcon; this.tribes = tribes; this.traits = traits; this.specialAbilities = specialAbilities; this.abilities = abilities; this.customAbilities = customAbilities; this.customSpecialAbilities = customSpecialAbilities; this.evolution = evolution; this.defaultEvolutionName = defaultEvolutionName; this.tail = tail; this.iceCube = iceCube; this.flipPortraitForStrafe = flipPortraitForStrafe; this.onePerDeck = onePerDeck; this.appearanceBehaviour = appearanceBehaviour; this.texture = texture; this.altTexture = altTexture; this.emissionTexture = emissionTexture; this.titleGraphic = titleGraphic; this.pixelTexture = pixelTexture; this.decals = decals; this.file = file; this.pluginName = pluginName; } public CardInfo ConvertCardObjectToCardInfo() { //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Expected O, but got Unknown //IL_0e30: Unknown result type (might be due to invalid IL or missing references) //IL_0e35: Unknown result type (might be due to invalid IL or missing references) //IL_0e70: Unknown result type (might be due to invalid IL or missing references) //IL_0e75: Unknown result type (might be due to invalid IL or missing references) //IL_0f54: Unknown result type (might be due to invalid IL or missing references) //IL_0f59: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_1133: Unknown result type (might be due to invalid IL or missing references) //IL_1139: Expected I4, but got Unknown //IL_1190: Unknown result type (might be due to invalid IL or missing references) //IL_1196: Expected I4, but got Unknown //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_0869: Unknown result type (might be due to invalid IL or missing references) //IL_086f: Expected I4, but got Unknown //IL_08de: Unknown result type (might be due to invalid IL or missing references) //IL_08e4: Expected I4, but got Unknown JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime CardMetaCategory Enums: (" + string.Join(", ", Enum.GetNames(typeof(CardMetaCategory))) + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime CardComplexity Enums: (" + string.Join(", ", Enum.GetNames(typeof(CardComplexity))) + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime CardTemple Enums: (" + string.Join(", ", Enum.GetNames(typeof(CardTemple))) + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime CardAppearanceBehaviour.Appearance Enums: (" + string.Join(", ", Enum.GetNames(typeof(Appearance))) + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime GemType Enums: (" + string.Join(", ", Enum.GetNames(typeof(GemType))) + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime SpecialStatIcon Enums: (" + string.Join(", ", Enum.GetNames(typeof(SpecialStatIcon))) + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime Tribe Enums: (" + string.Join(", ", Enum.GetNames(typeof(Tribe))) + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime Trait Enums: (" + string.Join(", ", Enum.GetNames(typeof(Trait))) + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime SpecialTriggeredAbility Enums: (" + string.Join(", ", Enum.GetNames(typeof(SpecialTriggeredAbility))) + ")"); JSONLoader3.FormatLogger("Debug", "CardUtils", "Runtime Ability Enums: (" + string.Join(", ", Enum.GetNames(typeof(Ability))) + ")"); CardInfo val = new CardInfo(); if (!LinqExtensions.IsNullOrEmpty((IList)fieldsToEdit)) { CardInfo val2 = ((IEnumerable)CardManager.BaseGameCards).FirstOrDefault((Func)((CardInfo x) => ((Object)x).name == name.Replace("Chaosyr.MADH95.Inscryption.JSON.CSVLoader_", ""))); if ((Object)(object)val2 != (Object)null) { val = val2; if (fieldsToEdit.Contains("description")) { val.description = description; } if (fieldsToEdit.Contains("displayedName")) { val.displayedName = displayedName; } if (fieldsToEdit.Contains("metaCategories") && metaCategories != null) { val.metaCategories = metaCategories.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (CardMetaCategory)Enum.Parse(typeof(CardMetaCategory), x))).ToList(); } if (fieldsToEdit.Contains("cardComplexity") && !string.IsNullOrEmpty(cardComplexity)) { val.cardComplexity = (CardComplexity)Enum.Parse(typeof(CardComplexity), cardComplexity); } if (fieldsToEdit.Contains("onePerDeck")) { val.onePerDeck = onePerDeck; } if (fieldsToEdit.Contains("temple") && !string.IsNullOrEmpty(temple)) { val.temple = (CardTemple)Enum.Parse(typeof(CardTemple), temple); } if (fieldsToEdit.Contains("hideAttackAndHealth")) { val.hideAttackAndHealth = hideAttackAndHealth; } if (fieldsToEdit.Contains("appearanceBehaviour") && appearanceBehaviour != null) { val.appearanceBehaviour = appearanceBehaviour.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (Appearance)Enum.Parse(typeof(Appearance), x))).ToList(); } if (fieldsToEdit.Contains("baseAttack")) { val.baseAttack = baseAttack; } if (fieldsToEdit.Contains("baseHealth")) { val.baseHealth = baseHealth; } if (fieldsToEdit.Contains("bloodCost")) { val.cost = bloodCost; } if (fieldsToEdit.Contains("bonesCost")) { val.bonesCost = bonesCost; } if (fieldsToEdit.Contains("energyCost")) { val.energyCost = energyCost; } if (fieldsToEdit.Contains("gemColors") && gemColors != null) { val.gemsCost = gemColors.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (GemType)Enum.Parse(typeof(GemType), x))).ToList(); } if (fieldsToEdit.Contains("specialStatIcon") && !string.IsNullOrEmpty(specialStatIcon)) { val.specialStatIcon = (SpecialStatIcon)Enum.Parse(typeof(SpecialStatIcon), specialStatIcon); } if (fieldsToEdit.Contains("tribes") && tribes != null) { val.tribes = tribes.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (Tribe)Enum.Parse(typeof(Tribe), x))).ToList(); } if (fieldsToEdit.Contains("traits") && traits != null) { val.traits = traits.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (Trait)Enum.Parse(typeof(Trait), x))).ToList(); } if (fieldsToEdit.Contains("specialAbilities") && specialAbilities != null) { val.specialAbilities = specialAbilities.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (SpecialTriggeredAbility)Enum.Parse(typeof(SpecialTriggeredAbility), x))).ToList(); } if (fieldsToEdit.Contains("abilities") && abilities != null) { val.abilities = abilities.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (Ability)Enum.Parse(typeof(Ability), x))).ToList(); } if (fieldsToEdit.Contains("customAbilities") && customAbilities != null) { foreach (AbilityData customAbility in customAbilities) { CardExtensions.AddAbilities(val, (Ability[])(object)new Ability[1] { (Ability)(int)customAbility.GetAbility() }); } } if (fieldsToEdit.Contains("customSpecialAbilities") && customSpecialAbilities != null) { foreach (SpecialAbilityData customSpecialAbility in customSpecialAbilities) { CardExtensions.AddSpecialAbilities(val, (SpecialTriggeredAbility[])(object)new SpecialTriggeredAbility[1] { (SpecialTriggeredAbility)(int)customSpecialAbility.GetSpecialAbility() }); } } if (fieldsToEdit.Contains("evolution") && evolution != null) { CardExtensions.SetEvolve(val, evolution.name, evolution.turnsToEvolve, (IEnumerable)null); } if (fieldsToEdit.Contains("defaultEvolutionName") && !string.IsNullOrEmpty(defaultEvolutionName)) { val.defaultEvolutionName = defaultEvolutionName; } if (fieldsToEdit.Contains("tail") && tail != null) { CardExtensions.SetTail(val, tail.name, tail.tailLostPortrait, (IEnumerable)null); } if (fieldsToEdit.Contains("iceCube") && iceCube != null) { CardExtensions.SetIceCube(val, iceCube.creatureWithin, (IEnumerable)null); } if (fieldsToEdit.Contains("flipPortraitForStrafe")) { val.flipPortraitForStrafe = flipPortraitForStrafe; } if (fieldsToEdit.Contains("texture") || fieldsToEdit.Contains("emissionTexture") || fieldsToEdit.Contains("altTexture") || fieldsToEdit.Contains("titleGraphic") || fieldsToEdit.Contains("pixelTexture") || fieldsToEdit.Contains("decals")) { string plugin = FindFiles.FindElementInPath(file, pluginName); if (fieldsToEdit.Contains("texture") || fieldsToEdit.Contains("emissionTexture")) { Sprite val3 = null; Sprite val4 = null; if (fieldsToEdit.Contains("texture") && !string.IsNullOrEmpty(texture)) { val3 = ScanImages.ParseImage(plugin, texture); } if (fieldsToEdit.Contains("emissionTexture") && !string.IsNullOrEmpty(emissionTexture)) { val4 = ScanImages.ParseImage(plugin, emissionTexture); } if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null) { CardExtensions.SetPortraitAndEmission(val, val3, val4); } else if ((Object)(object)val3 != (Object)null) { CardExtensions.SetPortrait(val, val3); } } if (fieldsToEdit.Contains("altTexture") && !string.IsNullOrEmpty(altTexture)) { Sprite val5 = ScanImages.ParseImage(plugin, altTexture); if ((Object)(object)val5 != (Object)null) { val.alternatePortrait = val5; } } if (fieldsToEdit.Contains("titleGraphic") && !string.IsNullOrEmpty(titleGraphic)) { Sprite val6 = ScanImages.ParseImage(plugin, titleGraphic); if ((Object)(object)val6 != (Object)null) { val.titleGraphic = (Texture)(object)val6.texture; } } if (fieldsToEdit.Contains("pixelTexture") && !string.IsNullOrEmpty(pixelTexture)) { Sprite val7 = ScanImages.ParseImage(plugin, pixelTexture); if ((Object)(object)val7 != (Object)null) { val.pixelPortrait = val7; } } if (fieldsToEdit.Contains("decals") && decals != null) { val.decals = new List(); foreach (string decal in decals) { if (!string.IsNullOrEmpty(decal)) { Sprite val8 = ScanImages.ParseImage(plugin, decal); if ((Object)(object)val8 != (Object)null) { val.decals.Add((Texture)(object)val8.texture); } } } } } } } else { val = CardManager.New("Chaosyr.MADH95.Inscryption.JSON.CSVLoader", name, displayedName, baseAttack, baseHealth, description); ((Object)val).name = name; val.displayedName = displayedName; val.description = description; if (metaCategories != null) { val.metaCategories = metaCategories.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (CardMetaCategory)Enum.Parse(typeof(CardMetaCategory), x))).ToList(); } if (!string.IsNullOrEmpty(cardComplexity)) { val.cardComplexity = (CardComplexity)Enum.Parse(typeof(CardComplexity), cardComplexity); } val.onePerDeck = onePerDeck; if (!string.IsNullOrEmpty(temple)) { val.temple = (CardTemple)Enum.Parse(typeof(CardTemple), temple); } val.hideAttackAndHealth = hideAttackAndHealth; val.baseAttack = baseAttack; val.baseHealth = baseHealth; val.cost = bloodCost; val.bonesCost = bonesCost; val.energyCost = energyCost; if (gemColors != null) { val.gemsCost = gemColors.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (GemType)Enum.Parse(typeof(GemType), x))).ToList(); } if (!string.IsNullOrEmpty(specialStatIcon)) { val.specialStatIcon = (SpecialStatIcon)Enum.Parse(typeof(SpecialStatIcon), specialStatIcon); } if (tribes != null) { val.tribes = tribes.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (Tribe)Enum.Parse(typeof(Tribe), x))).ToList(); } if (traits != null) { val.traits = traits.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (Trait)Enum.Parse(typeof(Trait), x))).ToList(); } if (specialAbilities != null) { val.specialAbilities = specialAbilities.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (SpecialTriggeredAbility)Enum.Parse(typeof(SpecialTriggeredAbility), x))).ToList(); } if (abilities != null) { val.abilities = abilities.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (Ability)Enum.Parse(typeof(Ability), x))).ToList(); } if (customAbilities != null) { foreach (AbilityData customAbility2 in customAbilities) { CardExtensions.AddAbilities(val, (Ability[])(object)new Ability[1] { (Ability)(int)customAbility2.GetAbility() }); } } if (customSpecialAbilities != null) { foreach (SpecialAbilityData customSpecialAbility2 in customSpecialAbilities) { CardExtensions.AddSpecialAbilities(val, (SpecialTriggeredAbility[])(object)new SpecialTriggeredAbility[1] { (SpecialTriggeredAbility)(int)customSpecialAbility2.GetSpecialAbility() }); } } if (evolution != null) { CardExtensions.SetEvolve(val, evolution.name, evolution.turnsToEvolve, (IEnumerable)null); } if (!string.IsNullOrEmpty(defaultEvolutionName)) { val.defaultEvolutionName = defaultEvolutionName; } if (tail != null) { CardExtensions.SetTail(val, tail.name, tail.tailLostPortrait, (IEnumerable)null); } if (iceCube != null) { CardExtensions.SetIceCube(val, iceCube.creatureWithin, (IEnumerable)null); } val.flipPortraitForStrafe = flipPortraitForStrafe; if (appearanceBehaviour != null) { val.appearanceBehaviour = appearanceBehaviour.Where((string x) => !string.IsNullOrEmpty(x)).Select((Func)((string x) => (Appearance)Enum.Parse(typeof(Appearance), x))).ToList(); } if (!string.IsNullOrEmpty(texture) || !string.IsNullOrEmpty(emissionTexture) || !string.IsNullOrEmpty(altTexture) || !string.IsNullOrEmpty(titleGraphic) || !string.IsNullOrEmpty(pixelTexture) || decals != null) { string text = pluginName; JSONLoader3.FormatLogger("Debug", "CardUtils", "Plugin Name: " + pluginName); JSONLoader3.FormatLogger("Debug", "CardUtils", "Plugin Path: " + text); JSONLoader3.FormatLogger("Debug", "CardUtils", "File Path: " + file); JSONLoader3.FormatLogger("Debug", "CardUtils", "Texture Path: " + texture); if (!string.IsNullOrEmpty(texture)) { Sprite val9 = ScanImages.ParseImage(text, texture); if ((Object)(object)val9 != (Object)null) { CardExtensions.SetPortrait(val, val9); } } if (!string.IsNullOrEmpty(emissionTexture)) { Sprite val10 = ScanImages.ParseImage(text, emissionTexture); if ((Object)(object)val10 != (Object)null) { CardExtensions.SetEmissivePortrait(val, val10); } } if (!string.IsNullOrEmpty(altTexture)) { Sprite val11 = ScanImages.ParseImage(text, altTexture); if ((Object)(object)val11 != (Object)null) { CardExtensions.SetAltPortrait(val, val11); } } if (!string.IsNullOrEmpty(titleGraphic)) { Sprite val12 = ScanImages.ParseImage(text, titleGraphic); if ((Object)(object)val12 != (Object)null) { val.titleGraphic = (Texture)(object)val12.texture; } } if (!string.IsNullOrEmpty(pixelTexture)) { Sprite val13 = ScanImages.ParseImage(text, pixelTexture); if ((Object)(object)val13 != (Object)null) { CardExtensions.SetPixelPortrait(val, val13); } } if (decals != null) { val.decals = new List(); foreach (string decal2 in decals) { if (!string.IsNullOrEmpty(decal2)) { Sprite val14 = ScanImages.ParseImage(text, decal2); if ((Object)(object)val14 != (Object)null) { CardExtensions.AddDecal(val, (Texture[])(object)new Texture[1] { (Texture)val14.texture }); } } } } } } return val; } } public class AbilityData { public string name { get; set; } public string GUID { get; set; } public AbilityData(string name, string GUID) { this.name = name; this.GUID = GUID; } public Ability GetAbility() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return GuidManager.GetEnumValue(GUID, name); } } public class SpecialAbilityData { public string name { get; set; } public string GUID { get; set; } public SpecialAbilityData(string name, string GUID) { this.name = name; this.GUID = GUID; } public SpecialTriggeredAbility GetSpecialAbility() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return GuidManager.GetEnumValue(GUID, name); } } public class EvolveData { public string name { get; set; } public int turnsToEvolve { get; set; } public EvolveData(string name, int turnsToEvolve) { this.name = name; this.turnsToEvolve = turnsToEvolve; } } public class TailData { public string name { get; set; } public string tailLostPortrait { get; set; } public TailData(string name, string tailLostPortrait) { this.name = name; this.tailLostPortrait = tailLostPortrait; } } public class IceCubeData { public string creatureWithin { get; set; } public IceCubeData(string creatureWithin) { this.creatureWithin = creatureWithin; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }