2
0

ModMod.cs 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.IO.Compression;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using System.Text;
  8. using System.Threading;
  9. using Microsoft.VisualBasic.CompilerServices;
  10. using Newtonsoft.Json;
  11. using Newtonsoft.Json.Linq;
  12. namespace PCL
  13. {
  14. // Token: 0x0200006E RID: 110
  15. [StandardModule]
  16. public sealed class ModMod
  17. {
  18. // Token: 0x06000297 RID: 663 RVA: 0x0001D2B8 File Offset: 0x0001B4B8
  19. private static void McModLoad(ModLoader.LoaderTask<string, List<ModMod.McMod>> Loader)
  20. {
  21. try
  22. {
  23. ModBase.RunInUiWait((ModMod._Closure$__.$I4-0 == null) ? (ModMod._Closure$__.$I4-0 = delegate()
  24. {
  25. if (ModMain._ThreadRepository != null)
  26. {
  27. ModMain._ThreadRepository.Load.ShowProgress = false;
  28. }
  29. }) : ModMod._Closure$__.$I4-0);
  30. if (PageVersionMod._RuleConfig.Contains(Loader.Input))
  31. {
  32. ModBase.Log("[Mod] 等待 Mod 更新完成后才能继续加载 Mod 列表:" + Loader.Input, ModBase.LogLevel.Normal, "出现错误");
  33. try
  34. {
  35. ModBase.RunInUiWait((ModMod._Closure$__.$I4-1 == null) ? (ModMod._Closure$__.$I4-1 = delegate()
  36. {
  37. if (ModMain._ThreadRepository != null)
  38. {
  39. ModMain._ThreadRepository.Load.Text = "正在更新 Mod";
  40. }
  41. }) : ModMod._Closure$__.$I4-1);
  42. while (PageVersionMod._RuleConfig.Contains(Loader.Input))
  43. {
  44. if (Loader.IsAborted)
  45. {
  46. return;
  47. }
  48. Thread.Sleep(100);
  49. }
  50. }
  51. finally
  52. {
  53. ModBase.RunInUiWait((ModMod._Closure$__.$I4-2 == null) ? (ModMod._Closure$__.$I4-2 = delegate()
  54. {
  55. if (ModMain._ThreadRepository != null)
  56. {
  57. ModMain._ThreadRepository.Load.Text = "正在加载 Mod 列表";
  58. }
  59. }) : ModMod._Closure$__.$I4-2);
  60. }
  61. ModMain._ThreadRepository.LoaderRun(ModLoader.LoaderFolderRunType.UpdateOnly);
  62. }
  63. List<FileInfo> list = new List<FileInfo>();
  64. if (Directory.Exists(Loader.Input))
  65. {
  66. string right = Loader.Input.ToLower();
  67. try
  68. {
  69. foreach (FileInfo fileInfo in ModBase.EnumerateFiles(Loader.Input))
  70. {
  71. if ((Operators.CompareString(fileInfo.DirectoryName.ToLower() + "\\", right, false) == 0 || (PageVersionLeft._InstanceConfig != null && PageVersionLeft._InstanceConfig.Version.m_StructMap && PageVersionLeft._InstanceConfig.Version._ServerMap < 13 && Operators.CompareString(fileInfo.Directory.Name, "1." + Conversions.ToString(PageVersionLeft._InstanceConfig.Version._ServerMap) + "." + Conversions.ToString(PageVersionLeft._InstanceConfig.Version.m_ResolverMap), false) == 0)) && Conversions.ToBoolean(ModMod.McMod.IsModFile(fileInfo.FullName)))
  72. {
  73. list.Add(fileInfo);
  74. }
  75. }
  76. }
  77. finally
  78. {
  79. IEnumerator<FileInfo> enumerator;
  80. if (enumerator != null)
  81. {
  82. enumerator.Dispose();
  83. }
  84. }
  85. }
  86. Loader.Progress = 0.05;
  87. if (list.Count > 50)
  88. {
  89. ModBase.RunInUi((ModMod._Closure$__.$I4-3 == null) ? (ModMod._Closure$__.$I4-3 = delegate()
  90. {
  91. if (ModMain._ThreadRepository != null)
  92. {
  93. ModMain._ThreadRepository.Load.ShowProgress = true;
  94. }
  95. }) : ModMod._Closure$__.$I4-3, false);
  96. }
  97. string filePath = ModBase.m_DecoratorRepository + "Cache\\LocalMod.json";
  98. JObject jobject = new JObject();
  99. try
  100. {
  101. string text = ModBase.ReadFile(filePath, null);
  102. if (!string.IsNullOrWhiteSpace(text))
  103. {
  104. jobject = (JObject)ModBase.GetJson(text);
  105. if (!jobject.ContainsKey("version") || jobject["version"].ToObject<int>() != 7)
  106. {
  107. ModBase.Log("[Mod] 本地 Mod 信息缓存版本已过期,将弃用这些缓存信息", ModBase.LogLevel.Debug, "出现错误");
  108. jobject = new JObject();
  109. }
  110. }
  111. }
  112. catch (Exception ex)
  113. {
  114. ModBase.Log(ex, "读取本地 Mod 信息缓存失败,已重置", ModBase.LogLevel.Debug, "出现错误");
  115. jobject = new JObject();
  116. }
  117. jobject["version"] = 7;
  118. List<ModMod.McMod> list2 = new List<ModMod.McMod>();
  119. List<ModMod.McMod> list3 = new List<ModMod.McMod>();
  120. try
  121. {
  122. foreach (FileInfo fileInfo2 in list)
  123. {
  124. ModMod._Closure$__4-0 CS$<>8__locals1 = new ModMod._Closure$__4-0(CS$<>8__locals1);
  125. Loader.Progress += 0.94 / (double)list.Count;
  126. if (Loader.IsAborted)
  127. {
  128. return;
  129. }
  130. CS$<>8__locals1.$VB$Local_ModEntry = new ModMod.McMod(fileInfo2.FullName);
  131. CS$<>8__locals1.$VB$Local_ModEntry.Load(false);
  132. ModMod.McMod mcMod = Enumerable.FirstOrDefault<ModMod.McMod>(list2, (ModMod.McMod m) => Operators.CompareString(m.ConcatTests(), CS$<>8__locals1.$VB$Local_ModEntry.ConcatTests(), false) == 0);
  133. if (mcMod != null)
  134. {
  135. ModMod.McMod mcMod2 = (mcMod.State == ModMod.McMod.McModState.Disabled) ? mcMod : CS$<>8__locals1.$VB$Local_ModEntry;
  136. ModBase.Log(string.Format("[Mod] 重复的 Mod 文件:{0} 与 {1},已忽略 {2}", mcMod.FileName, CS$<>8__locals1.$VB$Local_ModEntry.FileName, mcMod2.FileName), ModBase.LogLevel.Debug, "出现错误");
  137. if (mcMod2 == CS$<>8__locals1.$VB$Local_ModEntry)
  138. {
  139. continue;
  140. }
  141. list2.Remove(mcMod2);
  142. list3.Remove(mcMod2);
  143. }
  144. list2.Add(CS$<>8__locals1.$VB$Local_ModEntry);
  145. if (CS$<>8__locals1.$VB$Local_ModEntry.State != ModMod.McMod.McModState.Unavailable)
  146. {
  147. string text2 = CS$<>8__locals1.$VB$Local_ModEntry.ReflectMapper() + PageVersionLeft._InstanceConfig.Version._ConnectionMap + ModMod.GetTargetModLoaders().Join("");
  148. if (jobject.ContainsKey(text2))
  149. {
  150. CS$<>8__locals1.$VB$Local_ModEntry.FromJson((JObject)jobject[text2]);
  151. if (CS$<>8__locals1.$VB$Local_ModEntry.m_RepositoryTest && DateTime.Now - jobject[text2]["Comp"]["CacheTime"].ToObject<DateTime>() < new TimeSpan(6, 0, 0))
  152. {
  153. continue;
  154. }
  155. }
  156. list3.Add(CS$<>8__locals1.$VB$Local_ModEntry);
  157. }
  158. }
  159. }
  160. finally
  161. {
  162. List<FileInfo>.Enumerator enumerator2;
  163. ((IDisposable)enumerator2).Dispose();
  164. }
  165. Loader.Progress = 0.99;
  166. ModBase.Log(string.Format("[Mod] 共有 {0} 个 Mod,其中 {1} 个需要联网获取信息,{2} 个需要更新信息", list2.Count, Enumerable.Count<ModMod.McMod>(Enumerable.Where<ModMod.McMod>(list3, (ModMod._Closure$__.$I4-5 == null) ? (ModMod._Closure$__.$I4-5 = ((ModMod.McMod m) => m.Comp == null)) : ModMod._Closure$__.$I4-5)), Enumerable.Count<ModMod.McMod>(Enumerable.Where<ModMod.McMod>(list3, (ModMod._Closure$__.$I4-6 == null) ? (ModMod._Closure$__.$I4-6 = ((ModMod.McMod m) => m.Comp != null)) : ModMod._Closure$__.$I4-6))), ModBase.LogLevel.Normal, "出现错误");
  167. list2 = list2.Sort((ModMod._Closure$__.$I4-7 == null) ? (ModMod._Closure$__.$I4-7 = delegate(ModMod.McMod Left, ModMod.McMod Right)
  168. {
  169. bool result;
  170. if (Left.State == ModMod.McMod.McModState.Unavailable != (Right.State == ModMod.McMod.McModState.Unavailable))
  171. {
  172. result = (Left.State == ModMod.McMod.McModState.Unavailable);
  173. }
  174. else
  175. {
  176. result = (~Right.FileName.CompareTo(Left.FileName) != 0);
  177. }
  178. return result;
  179. }) : ModMod._Closure$__.$I4-7);
  180. if (!Loader.IsAborted)
  181. {
  182. Loader.Output = list2;
  183. if (Enumerable.Any<ModMod.McMod>(list3))
  184. {
  185. ModMod.m_Service.Start(new KeyValuePair<List<ModMod.McMod>, JObject>(list3, jobject), true);
  186. }
  187. }
  188. }
  189. catch (Exception ex2)
  190. {
  191. ModBase.Log(ex2, "Mod 列表加载失败", ModBase.LogLevel.Debug, "出现错误");
  192. throw;
  193. }
  194. }
  195. // Token: 0x06000298 RID: 664 RVA: 0x0001D914 File Offset: 0x0001BB14
  196. private static void McModDetailLoad(ModLoader.LoaderTask<KeyValuePair<List<ModMod.McMod>, JObject>, int> Loader)
  197. {
  198. ModMod._Closure$__6-0 CS$<>8__locals1 = new ModMod._Closure$__6-0(CS$<>8__locals1);
  199. CS$<>8__locals1.$VB$Local_Loader = Loader;
  200. CS$<>8__locals1.$VB$Local_Mods = CS$<>8__locals1.$VB$Local_Loader.Input.Key;
  201. JObject value = CS$<>8__locals1.$VB$Local_Loader.Input.Value;
  202. ModMinecraft.McVersionInfo version = PageVersionLeft._InstanceConfig.Version;
  203. CS$<>8__locals1.$VB$Local_ModLoaders = ModMod.GetTargetModLoaders();
  204. CS$<>8__locals1.$VB$Local_McVersion = version._ConnectionMap;
  205. ModBase.Log(string.Format("[Mod] 目标加载器:{0},版本:{1}", CS$<>8__locals1.$VB$Local_ModLoaders.Join("/"), CS$<>8__locals1.$VB$Local_McVersion), ModBase.LogLevel.Normal, "出现错误");
  206. CS$<>8__locals1.$VB$Local_EndedThreadCount = 0;
  207. CS$<>8__locals1.$VB$Local_IsFailed = false;
  208. CS$<>8__locals1.$VB$Local_MainThread = Thread.CurrentThread;
  209. checked
  210. {
  211. ModBase.RunInNewThread(delegate
  212. {
  213. try
  214. {
  215. List<string> list = Enumerable.ToList<string>(Enumerable.Select<ModMod.McMod, string>(CS$<>8__locals1.$VB$Local_Mods, (ModMod._Closure$__.$I6-1 == null) ? (ModMod._Closure$__.$I6-1 = ((ModMod.McMod m) => m.ReflectMapper())) : ModMod._Closure$__.$I6-1));
  216. JObject jobject = (JObject)ModBase.GetJson(ModDownload.DlModRequest("https://api.modrinth.com/v2/version_files", "POST", string.Format("{{\"hashes\": [\"{0}\"], \"algorithm\": \"sha1\"}}", list.Join("\",\"")), "application/json"));
  217. ModBase.Log(string.Format("[Mod] 从 Modrinth 获取到 {0} 个本地 Mod 的对应信息", jobject.Count), ModBase.LogLevel.Normal, "出现错误");
  218. if (jobject.Count != 0)
  219. {
  220. Dictionary<string, List<ModMod.McMod>> dictionary = new Dictionary<string, List<ModMod.McMod>>();
  221. try
  222. {
  223. foreach (ModMod.McMod mcMod2 in CS$<>8__locals1.$VB$Local_Mods)
  224. {
  225. if (jobject.ContainsKey(mcMod2.ReflectMapper()) && !((string)jobject[mcMod2.ReflectMapper()]["files"][0]["hashes"]["sha1"] != mcMod2.ReflectMapper()))
  226. {
  227. string key = jobject[mcMod2.ReflectMapper()]["project_id"].ToString();
  228. if (ModComp.pool.ContainsKey(key) && mcMod2.Comp == null)
  229. {
  230. mcMod2.Comp = ModComp.pool[key];
  231. }
  232. if (!dictionary.ContainsKey(key))
  233. {
  234. dictionary[key] = new List<ModMod.McMod>();
  235. }
  236. dictionary[key].Add(mcMod2);
  237. ModComp.CompFile compFile = new ModComp.CompFile((JObject)jobject[mcMod2.ReflectMapper()], ModComp.CompType.Mod);
  238. if (mcMod2._PropertyTest == null || DateTime.Compare(mcMod2._PropertyTest._ListenerRepository, compFile._ListenerRepository) < 0)
  239. {
  240. mcMod2._PropertyTest = compFile;
  241. }
  242. }
  243. }
  244. }
  245. finally
  246. {
  247. List<ModMod.McMod>.Enumerator enumerator2;
  248. ((IDisposable)enumerator2).Dispose();
  249. }
  250. if (!CS$<>8__locals1.$VB$Local_Loader.IsAbortedWithThread(CS$<>8__locals1.$VB$Local_MainThread))
  251. {
  252. ModBase.Log(string.Format("[Mod] 需要从 Modrinth 获取 {0} 个本地 Mod 的工程信息", dictionary.Count), ModBase.LogLevel.Normal, "出现错误");
  253. if (Enumerable.Any<KeyValuePair<string, List<ModMod.McMod>>>(dictionary))
  254. {
  255. JArray jarray = (JArray)ModBase.GetJson(ModDownload.DlModRequest(string.Format("https://api.modrinth.com/v2/projects?ids=[\"{0}\"]", dictionary.Keys.Join("\",\"")), "GET", "", "application/json"));
  256. try
  257. {
  258. foreach (JToken jtoken in jarray)
  259. {
  260. ModComp.CompProject compProject = new ModComp.CompProject((JObject)jtoken);
  261. try
  262. {
  263. foreach (ModMod.McMod mcMod3 in dictionary[compProject._AuthenticationRepository])
  264. {
  265. mcMod3.Comp = compProject;
  266. }
  267. }
  268. finally
  269. {
  270. List<ModMod.McMod>.Enumerator enumerator4;
  271. ((IDisposable)enumerator4).Dispose();
  272. }
  273. }
  274. }
  275. finally
  276. {
  277. IEnumerator<JToken> enumerator3;
  278. if (enumerator3 != null)
  279. {
  280. enumerator3.Dispose();
  281. }
  282. }
  283. ModBase.Log("[Mod] 已从 Modrinth 获取本地 Mod 信息,继续获取更新信息", ModBase.LogLevel.Normal, "出现错误");
  284. JObject jobject2 = (JObject)ModBase.GetJson(ModDownload.DlModRequest("https://api.modrinth.com/v2/version_files/update", "POST", string.Format("{{\"hashes\": [\"{0}\"], \"algorithm\": \"sha1\", \r\n \"loaders\": [\"{1}\"],\"game_versions\": [\"{2}\"]}}", Enumerable.SelectMany<KeyValuePair<string, List<ModMod.McMod>>, string>(dictionary, (ModMod._Closure$__.$I6-2 == null) ? (ModMod._Closure$__.$I6-2 = ((KeyValuePair<string, List<ModMod.McMod>> l) => Enumerable.Select<ModMod.McMod, string>(l.Value, (ModMod._Closure$__.$I6-3 == null) ? (ModMod._Closure$__.$I6-3 = ((ModMod.McMod m) => m.ReflectMapper())) : ModMod._Closure$__.$I6-3))) : ModMod._Closure$__.$I6-2).Join("\",\""), CS$<>8__locals1.$VB$Local_ModLoaders.Join("\",\"").ToLower(), CS$<>8__locals1.$VB$Local_McVersion), "application/json"));
  285. try
  286. {
  287. foreach (ModMod.McMod mcMod4 in CS$<>8__locals1.$VB$Local_Mods)
  288. {
  289. if (jobject2.ContainsKey(mcMod4.ReflectMapper()) && mcMod4._PropertyTest != null)
  290. {
  291. ModComp.CompFile compFile2 = new ModComp.CompFile((JObject)jobject2[mcMod4.ReflectMapper()], ModComp.CompType.Mod);
  292. if (compFile2.ExcludeTests())
  293. {
  294. if (ModBase._TokenRepository)
  295. {
  296. ModBase.Log(string.Format("[Mod] 本地文件 {0} 在 Modrinth 上的最新版为 {1}", mcMod4._PropertyTest._BridgeRepository, compFile2._BridgeRepository), ModBase.LogLevel.Normal, "出现错误");
  297. }
  298. if (DateTime.Compare(mcMod4._PropertyTest._ListenerRepository, compFile2._ListenerRepository) < 0 && Operators.CompareString(mcMod4._PropertyTest.m_ReponseRepository, compFile2.m_ReponseRepository, false) != 0)
  299. {
  300. if (mcMod4.UpdateFile != null && Operators.CompareString(compFile2.m_ReponseRepository, mcMod4.UpdateFile.m_ReponseRepository, false) == 0)
  301. {
  302. mcMod4.m_IteratorTest.Add(string.Format("https://modrinth.com/mod/{0}/changelog?g={1}", jobject2[mcMod4.ReflectMapper()]["project_id"], CS$<>8__locals1.$VB$Local_McVersion));
  303. compFile2._ItemRepository.AddRange(mcMod4.UpdateFile._ItemRepository);
  304. mcMod4.UpdateFile = compFile2;
  305. }
  306. else if (mcMod4.UpdateFile == null || DateTime.Compare(compFile2._ListenerRepository, mcMod4.UpdateFile._ListenerRepository) >= 0)
  307. {
  308. mcMod4.m_IteratorTest = new List<string>
  309. {
  310. string.Format("https://modrinth.com/mod/{0}/changelog?g={1}", jobject2[mcMod4.ReflectMapper()]["project_id"], CS$<>8__locals1.$VB$Local_McVersion)
  311. };
  312. mcMod4.UpdateFile = compFile2;
  313. }
  314. }
  315. }
  316. }
  317. }
  318. }
  319. finally
  320. {
  321. List<ModMod.McMod>.Enumerator enumerator5;
  322. ((IDisposable)enumerator5).Dispose();
  323. }
  324. ModBase.Log("[Mod] 从 Modrinth 获取本地 Mod 信息结束", ModBase.LogLevel.Normal, "出现错误");
  325. }
  326. }
  327. }
  328. }
  329. catch (Exception ex)
  330. {
  331. ModBase.Log(ex, "从 Modrinth 获取本地 Mod 信息失败", ModBase.LogLevel.Debug, "出现错误");
  332. CS$<>8__locals1.$VB$Local_IsFailed = true;
  333. }
  334. finally
  335. {
  336. CS$<>8__locals1.$VB$Local_EndedThreadCount++;
  337. }
  338. }, "Mod List Detail Loader Modrinth", ThreadPriority.Normal);
  339. ModBase.RunInNewThread(delegate
  340. {
  341. try
  342. {
  343. List<uint> list = new List<uint>();
  344. try
  345. {
  346. foreach (ModMod.McMod mcMod2 in CS$<>8__locals1.$VB$Local_Mods)
  347. {
  348. list.Add(mcMod2.LogoutMapper());
  349. if (CS$<>8__locals1.$VB$Local_Loader.IsAbortedWithThread(CS$<>8__locals1.$VB$Local_MainThread))
  350. {
  351. return;
  352. }
  353. }
  354. }
  355. finally
  356. {
  357. List<ModMod.McMod>.Enumerator enumerator2;
  358. ((IDisposable)enumerator2).Dispose();
  359. }
  360. JContainer jcontainer = (JContainer)((JObject)ModBase.GetJson(ModDownload.DlModRequest("https://api.curseforge.com/v1/fingerprints/432", "POST", string.Format("{{\"fingerprints\": [{0}]}}", list.Join(",")), "application/json")))["data"]["exactMatches"];
  361. ModBase.Log(string.Format("[Mod] 从 CurseForge 获取到 {0} 个本地 Mod 的对应信息", jcontainer.Count), ModBase.LogLevel.Normal, "出现错误");
  362. if (Enumerable.Any<JToken>(jcontainer))
  363. {
  364. Dictionary<int, List<ModMod.McMod>> dictionary = new Dictionary<int, List<ModMod.McMod>>();
  365. try
  366. {
  367. foreach (JToken jtoken in jcontainer)
  368. {
  369. string text = jtoken["id"].ToString();
  370. uint num = (uint)jtoken["file"]["fileFingerprint"];
  371. try
  372. {
  373. foreach (ModMod.McMod mcMod3 in CS$<>8__locals1.$VB$Local_Mods)
  374. {
  375. if (mcMod3.LogoutMapper() == num)
  376. {
  377. if (ModComp.pool.ContainsKey(text) && mcMod3.Comp == null)
  378. {
  379. mcMod3.Comp = ModComp.pool[text];
  380. }
  381. if (!dictionary.ContainsKey(Conversions.ToInteger(text)))
  382. {
  383. dictionary[Conversions.ToInteger(text)] = new List<ModMod.McMod>();
  384. }
  385. dictionary[Conversions.ToInteger(text)].Add(mcMod3);
  386. ModComp.CompFile compFile = new ModComp.CompFile((JObject)jtoken["file"], ModComp.CompType.Mod);
  387. if (mcMod3._PropertyTest == null || DateTime.Compare(mcMod3._PropertyTest._ListenerRepository, compFile._ListenerRepository) < 0)
  388. {
  389. mcMod3._PropertyTest = compFile;
  390. }
  391. }
  392. }
  393. }
  394. finally
  395. {
  396. List<ModMod.McMod>.Enumerator enumerator4;
  397. ((IDisposable)enumerator4).Dispose();
  398. }
  399. }
  400. }
  401. finally
  402. {
  403. IEnumerator<JToken> enumerator3;
  404. if (enumerator3 != null)
  405. {
  406. enumerator3.Dispose();
  407. }
  408. }
  409. if (!CS$<>8__locals1.$VB$Local_Loader.IsAbortedWithThread(CS$<>8__locals1.$VB$Local_MainThread))
  410. {
  411. ModBase.Log(string.Format("[Mod] 需要从 CurseForge 获取 {0} 个本地 Mod 的工程信息", dictionary.Count), ModBase.LogLevel.Normal, "出现错误");
  412. if (Enumerable.Any<KeyValuePair<int, List<ModMod.McMod>>>(dictionary))
  413. {
  414. JToken jtoken2 = ((JObject)ModBase.GetJson(ModDownload.DlModRequest("https://api.curseforge.com/v1/mods", "POST", string.Format("{{\"modIds\": [{0}]}}", dictionary.Keys.Join(",")), "application/json")))["data"];
  415. Dictionary<int, List<ModMod.McMod>> dictionary2 = new Dictionary<int, List<ModMod.McMod>>();
  416. Dictionary<int, string> dictionary3 = new Dictionary<int, string>();
  417. try
  418. {
  419. foreach (JToken jtoken3 in jtoken2)
  420. {
  421. if (jtoken3["isAvailable"] == null || jtoken3["isAvailable"].ToObject<bool>())
  422. {
  423. ModComp.CompProject compProject = new ModComp.CompProject((JObject)jtoken3);
  424. try
  425. {
  426. foreach (ModMod.McMod mcMod4 in dictionary[Conversions.ToInteger(compProject._AuthenticationRepository)])
  427. {
  428. if (mcMod4.Comp != null && !mcMod4.Comp.listRepository)
  429. {
  430. mcMod4.Comp = mcMod4.Comp;
  431. }
  432. else
  433. {
  434. mcMod4.Comp = compProject;
  435. }
  436. }
  437. }
  438. finally
  439. {
  440. List<ModMod.McMod>.Enumerator enumerator6;
  441. ((IDisposable)enumerator6).Dispose();
  442. }
  443. if (CS$<>8__locals1.$VB$Local_ModLoaders.Count == 1)
  444. {
  445. string text2 = null;
  446. List<int> list2 = new List<int>();
  447. try
  448. {
  449. foreach (JToken jtoken4 in jtoken3["latestFilesIndexes"])
  450. {
  451. if (jtoken4["modLoader"] != null && Enumerable.Single<ModComp.CompModLoaderType>(CS$<>8__locals1.$VB$Local_ModLoaders) == (ModComp.CompModLoaderType)jtoken4["modLoader"].ToObject<int>())
  452. {
  453. string text3 = (string)jtoken4["gameVersion"];
  454. if (Operators.CompareString(text3, CS$<>8__locals1.$VB$Local_McVersion, false) == 0 && (text2 == null || ModMinecraft.VersionSortInteger(text2, text3) <= -1))
  455. {
  456. if (Operators.CompareString(text2, text3, false) != 0)
  457. {
  458. text2 = text3;
  459. list2.Clear();
  460. }
  461. list2.Add(jtoken4["fileId"].ToObject<int>());
  462. }
  463. }
  464. }
  465. }
  466. finally
  467. {
  468. IEnumerator<JToken> enumerator7;
  469. if (enumerator7 != null)
  470. {
  471. enumerator7.Dispose();
  472. }
  473. }
  474. try
  475. {
  476. foreach (int key in list2)
  477. {
  478. if (!dictionary2.ContainsKey(key))
  479. {
  480. dictionary2[key] = new List<ModMod.McMod>();
  481. }
  482. dictionary2[key].AddRange(dictionary[Conversions.ToInteger(compProject._AuthenticationRepository)]);
  483. dictionary3[key] = compProject.m_MerchantRepository;
  484. }
  485. }
  486. finally
  487. {
  488. List<int>.Enumerator enumerator8;
  489. ((IDisposable)enumerator8).Dispose();
  490. }
  491. }
  492. }
  493. }
  494. }
  495. finally
  496. {
  497. IEnumerator<JToken> enumerator5;
  498. if (enumerator5 != null)
  499. {
  500. enumerator5.Dispose();
  501. }
  502. }
  503. ModBase.Log(string.Format("[Mod] 已从 CurseForge 获取本地 Mod 信息,需要获取 {0} 个用于检查更新的文件信息", dictionary2.Count), ModBase.LogLevel.Normal, "出现错误");
  504. if (Enumerable.Any<KeyValuePair<int, List<ModMod.McMod>>>(dictionary2))
  505. {
  506. JToken jtoken5 = ((JObject)ModBase.GetJson(ModDownload.DlModRequest("https://api.curseforge.com/v1/mods/files", "POST", string.Format("{{\"fileIds\": [{0}]}}", dictionary2.Keys.Join(",")), "application/json")))["data"];
  507. Dictionary<ModMod.McMod, ModComp.CompFile> dictionary4 = new Dictionary<ModMod.McMod, ModComp.CompFile>();
  508. try
  509. {
  510. foreach (JToken jtoken6 in jtoken5)
  511. {
  512. ModComp.CompFile compFile2 = new ModComp.CompFile((JObject)jtoken6, ModComp.CompType.Mod);
  513. if (compFile2.ExcludeTests())
  514. {
  515. try
  516. {
  517. foreach (ModMod.McMod key2 in dictionary2[Conversions.ToInteger(compFile2.m_RegRepository)])
  518. {
  519. if (!dictionary4.ContainsKey(key2) || DateTime.Compare(dictionary4[key2]._ListenerRepository, compFile2._ListenerRepository) < 0)
  520. {
  521. dictionary4[key2] = compFile2;
  522. }
  523. }
  524. }
  525. finally
  526. {
  527. List<ModMod.McMod>.Enumerator enumerator10;
  528. ((IDisposable)enumerator10).Dispose();
  529. }
  530. }
  531. }
  532. }
  533. finally
  534. {
  535. IEnumerator<JToken> enumerator9;
  536. if (enumerator9 != null)
  537. {
  538. enumerator9.Dispose();
  539. }
  540. }
  541. try
  542. {
  543. foreach (KeyValuePair<ModMod.McMod, ModComp.CompFile> keyValuePair in dictionary4)
  544. {
  545. ModMod.McMod key3 = keyValuePair.Key;
  546. ModComp.CompFile value2 = keyValuePair.Value;
  547. if (ModBase._TokenRepository)
  548. {
  549. ModBase.Log(string.Format("[Mod] 本地文件 {0} 在 CurseForge 上的最新版为 {1}", key3._PropertyTest._BridgeRepository, value2._BridgeRepository), ModBase.LogLevel.Normal, "出现错误");
  550. }
  551. if (DateTime.Compare(key3._PropertyTest._ListenerRepository, value2._ListenerRepository) < 0 && Operators.CompareString(key3._PropertyTest.m_ReponseRepository, value2.m_ReponseRepository, false) != 0)
  552. {
  553. if (key3.UpdateFile != null && Operators.CompareString(value2.m_ReponseRepository, key3.UpdateFile.m_ReponseRepository, false) == 0)
  554. {
  555. key3.m_IteratorTest.Add(string.Format("https://www.curseforge.com/minecraft/mc-mods/{0}/files/{1}", dictionary3[Conversions.ToInteger(value2.m_RegRepository)], value2.m_RegRepository));
  556. key3.UpdateFile._ItemRepository.AddRange(value2._ItemRepository);
  557. }
  558. else if (key3.UpdateFile == null || DateTime.Compare(value2._ListenerRepository, key3.UpdateFile._ListenerRepository) > 0)
  559. {
  560. key3.m_IteratorTest = new List<string>
  561. {
  562. string.Format("https://www.curseforge.com/minecraft/mc-mods/{0}/files/{1}", dictionary3[Conversions.ToInteger(value2.m_RegRepository)], value2.m_RegRepository)
  563. };
  564. key3.UpdateFile = value2;
  565. }
  566. }
  567. }
  568. }
  569. finally
  570. {
  571. Dictionary<ModMod.McMod, ModComp.CompFile>.Enumerator enumerator11;
  572. ((IDisposable)enumerator11).Dispose();
  573. }
  574. ModBase.Log("[Mod] 从 CurseForge 获取 Mod 更新信息结束", ModBase.LogLevel.Normal, "出现错误");
  575. }
  576. }
  577. }
  578. }
  579. }
  580. catch (Exception ex)
  581. {
  582. ModBase.Log(ex, "从 CurseForge 获取本地 Mod 信息失败", ModBase.LogLevel.Debug, "出现错误");
  583. CS$<>8__locals1.$VB$Local_IsFailed = true;
  584. }
  585. finally
  586. {
  587. CS$<>8__locals1.$VB$Local_EndedThreadCount++;
  588. }
  589. }, "Mod List Detail Loader CurseForge", ThreadPriority.Normal);
  590. while (CS$<>8__locals1.$VB$Local_EndedThreadCount != 2)
  591. {
  592. if (CS$<>8__locals1.$VB$Local_Loader.IsAborted)
  593. {
  594. return;
  595. }
  596. Thread.Sleep(10);
  597. }
  598. CS$<>8__locals1.$VB$Local_Mods = Enumerable.ToList<ModMod.McMod>(Enumerable.Where<ModMod.McMod>(CS$<>8__locals1.$VB$Local_Mods, (ModMod._Closure$__.$I6-5 == null) ? (ModMod._Closure$__.$I6-5 = ((ModMod.McMod m) => m.Comp != null)) : ModMod._Closure$__.$I6-5));
  599. ModBase.Log(string.Format("[Mod] 联网获取本地 Mod 信息完成,为 {0} 个 Mod 更新缓存", CS$<>8__locals1.$VB$Local_Mods.Count), ModBase.LogLevel.Normal, "出现错误");
  600. if (Enumerable.Any<ModMod.McMod>(CS$<>8__locals1.$VB$Local_Mods))
  601. {
  602. try
  603. {
  604. foreach (ModMod.McMod mcMod in CS$<>8__locals1.$VB$Local_Mods)
  605. {
  606. mcMod.m_RepositoryTest = !CS$<>8__locals1.$VB$Local_IsFailed;
  607. value[mcMod.ReflectMapper() + CS$<>8__locals1.$VB$Local_McVersion + CS$<>8__locals1.$VB$Local_ModLoaders.Join("")] = mcMod.ToJson();
  608. }
  609. }
  610. finally
  611. {
  612. List<ModMod.McMod>.Enumerator enumerator;
  613. ((IDisposable)enumerator).Dispose();
  614. }
  615. ModBase.WriteFile(ModBase.m_DecoratorRepository + "Cache\\LocalMod.json", value.ToString(ModBase._TokenRepository ? 1 : 0, new JsonConverter[0]), false, null);
  616. ModBase.RunInUi((ModMod._Closure$__.$I6-6 == null) ? (ModMod._Closure$__.$I6-6 = delegate()
  617. {
  618. PageVersionMod threadRepository = ModMain._ThreadRepository;
  619. if (threadRepository == null)
  620. {
  621. return;
  622. }
  623. threadRepository.RefreshBars();
  624. }) : ModMod._Closure$__.$I6-6, false);
  625. return;
  626. }
  627. }
  628. }
  629. // Token: 0x06000299 RID: 665 RVA: 0x0001DB54 File Offset: 0x0001BD54
  630. private static List<ModComp.CompModLoaderType> GetTargetModLoaders()
  631. {
  632. List<ModComp.CompModLoaderType> list = new List<ModComp.CompModLoaderType>();
  633. if (PageVersionLeft._InstanceConfig.Version.m_StructMap)
  634. {
  635. list.Add(ModComp.CompModLoaderType.Forge);
  636. }
  637. if (PageVersionLeft._InstanceConfig.Version._ValMap)
  638. {
  639. list.Add(ModComp.CompModLoaderType.NeoForge);
  640. }
  641. if (PageVersionLeft._InstanceConfig.Version._CandidateMap)
  642. {
  643. list.Add(ModComp.CompModLoaderType.Fabric);
  644. }
  645. if (PageVersionLeft._InstanceConfig.Version._AccountMap)
  646. {
  647. list.Add(ModComp.CompModLoaderType.LiteLoader);
  648. }
  649. if (!Enumerable.Any<ModComp.CompModLoaderType>(list))
  650. {
  651. list.AddRange(new ModComp.CompModLoaderType[]
  652. {
  653. ModComp.CompModLoaderType.Forge,
  654. ModComp.CompModLoaderType.NeoForge,
  655. ModComp.CompModLoaderType.Fabric,
  656. ModComp.CompModLoaderType.LiteLoader,
  657. ModComp.CompModLoaderType.Quilt
  658. });
  659. }
  660. return list;
  661. }
  662. // Token: 0x04000185 RID: 389
  663. public static ModLoader.LoaderTask<string, List<ModMod.McMod>> m_Record = new ModLoader.LoaderTask<string, List<ModMod.McMod>>("Mod List Loader", new Action<ModLoader.LoaderTask<string, List<ModMod.McMod>>>(ModMod.McModLoad), null, ThreadPriority.Normal);
  664. // Token: 0x04000186 RID: 390
  665. public static ModLoader.LoaderTask<KeyValuePair<List<ModMod.McMod>, JObject>, int> m_Service = new ModLoader.LoaderTask<KeyValuePair<List<ModMod.McMod>, JObject>, int>("Mod List Detail Loader", new Action<ModLoader.LoaderTask<KeyValuePair<List<ModMod.McMod>, JObject>, int>>(ModMod.McModDetailLoad), null, ThreadPriority.Normal);
  666. // Token: 0x0200006F RID: 111
  667. public class McMod
  668. {
  669. // Token: 0x0600029A RID: 666 RVA: 0x0001DBE8 File Offset: 0x0001BDE8
  670. public McMod(string Path)
  671. {
  672. this.m_SchemaRepository = null;
  673. this.m_DescriptorRepository = null;
  674. this._PublisherRepository = null;
  675. this._DefinitionRepository = null;
  676. this._StrategyRepository = new List<string>();
  677. this.m_ProcRepository = null;
  678. this._ParserTest = null;
  679. this.broadcasterTest = new Dictionary<string, string>();
  680. this.m_FieldTest = false;
  681. this._ReaderTest = null;
  682. this._ClientTest = false;
  683. this._ConfigTest = false;
  684. this._TestsTest = false;
  685. this.m_IteratorTest = new List<string>();
  686. this.m_RepositoryTest = false;
  687. this.Path = (Path ?? "");
  688. }
  689. // Token: 0x0600029B RID: 667 RVA: 0x000039F2 File Offset: 0x00001BF2
  690. public string CustomizeTests()
  691. {
  692. return ModBase.GetPathFromFullPath(this.Path) + this.ConcatTests();
  693. }
  694. // Token: 0x17000025 RID: 37
  695. // (get) Token: 0x0600029C RID: 668 RVA: 0x00003A0A File Offset: 0x00001C0A
  696. public string FileName
  697. {
  698. get
  699. {
  700. return ModBase.GetFileNameFromPath(this.Path);
  701. }
  702. }
  703. // Token: 0x0600029D RID: 669 RVA: 0x00003A17 File Offset: 0x00001C17
  704. public string ConcatTests()
  705. {
  706. return this.FileName.Replace(".disabled", "").Replace(".old", "");
  707. }
  708. // Token: 0x17000026 RID: 38
  709. // (get) Token: 0x0600029E RID: 670 RVA: 0x0001DC84 File Offset: 0x0001BE84
  710. public ModMod.McMod.McModState State
  711. {
  712. get
  713. {
  714. this.Load(false);
  715. ModMod.McMod.McModState result;
  716. if (!this.SortMapper())
  717. {
  718. result = ModMod.McMod.McModState.Unavailable;
  719. }
  720. else if (!this.Path.EndsWithF(".disabled", true) && !this.Path.EndsWithF(".old", true))
  721. {
  722. result = ModMod.McMod.McModState.Fine;
  723. }
  724. else
  725. {
  726. result = ModMod.McMod.McModState.Disabled;
  727. }
  728. return result;
  729. }
  730. }
  731. // Token: 0x17000027 RID: 39
  732. // (get) Token: 0x0600029F RID: 671 RVA: 0x0001DCD4 File Offset: 0x0001BED4
  733. // (set) Token: 0x060002A0 RID: 672 RVA: 0x0001DD24 File Offset: 0x0001BF24
  734. public string Name
  735. {
  736. get
  737. {
  738. if (this.m_SchemaRepository == null)
  739. {
  740. this.Load(false);
  741. }
  742. if (this.m_SchemaRepository == null)
  743. {
  744. this.m_SchemaRepository = this._DefinitionRepository;
  745. }
  746. if (this.m_SchemaRepository == null)
  747. {
  748. this.m_SchemaRepository = ModBase.GetFileNameWithoutExtentionFromPath(this.Path);
  749. }
  750. return this.m_SchemaRepository;
  751. }
  752. set
  753. {
  754. if (this.m_SchemaRepository == null && value != null && !value.Contains("modname") && Operators.CompareString(value.ToLower(), "name", false) != 0 && Enumerable.Count<char>(value) > 1 && Operators.CompareString(ModBase.Val(value).ToString(), value, false) != 0)
  755. {
  756. this.m_SchemaRepository = value;
  757. }
  758. }
  759. }
  760. // Token: 0x17000028 RID: 40
  761. // (get) Token: 0x060002A1 RID: 673 RVA: 0x00003A3D File Offset: 0x00001C3D
  762. // (set) Token: 0x060002A2 RID: 674 RVA: 0x0001DD84 File Offset: 0x0001BF84
  763. public string Description
  764. {
  765. get
  766. {
  767. if (this.m_DescriptorRepository == null)
  768. {
  769. this.Load(false);
  770. }
  771. if (this.m_DescriptorRepository == null && this.SetupMapper() != null)
  772. {
  773. this.m_DescriptorRepository = this.SetupMapper().Message;
  774. }
  775. return this.m_DescriptorRepository;
  776. }
  777. set
  778. {
  779. if (this.m_DescriptorRepository == null && value != null && Enumerable.Count<char>(value) > 2)
  780. {
  781. this.m_DescriptorRepository = value.ToString().Trim(new char[]
  782. {
  783. '\n'
  784. });
  785. if (this.m_DescriptorRepository.ToLower().LastIndexOfAny(Conversions.ToCharArrayRankOne("qwertyuiopasdfghjklzxcvbnm0123456789")) == checked(Enumerable.Count<char>(this.m_DescriptorRepository) - 1))
  786. {
  787. ref string ptr = ref this.m_DescriptorRepository;
  788. this.m_DescriptorRepository = ptr + ".";
  789. }
  790. }
  791. }
  792. }
  793. // Token: 0x17000029 RID: 41
  794. // (get) Token: 0x060002A3 RID: 675 RVA: 0x00003A75 File Offset: 0x00001C75
  795. // (set) Token: 0x060002A4 RID: 676 RVA: 0x00003A8C File Offset: 0x00001C8C
  796. public string Version
  797. {
  798. get
  799. {
  800. if (this._PublisherRepository == null)
  801. {
  802. this.Load(false);
  803. }
  804. return this._PublisherRepository;
  805. }
  806. set
  807. {
  808. if (this._PublisherRepository == null || !ModBase.RegexCheck(this._PublisherRepository, "[0-9.\\-]+", 0))
  809. {
  810. if (value != null && value.ContainsF("version", true))
  811. {
  812. value = "version";
  813. }
  814. this._PublisherRepository = value;
  815. }
  816. }
  817. }
  818. // Token: 0x060002A5 RID: 677 RVA: 0x00003ACB File Offset: 0x00001CCB
  819. public string LoginMapper()
  820. {
  821. if (this._DefinitionRepository == null)
  822. {
  823. this.Load(false);
  824. }
  825. return this._DefinitionRepository;
  826. }
  827. // Token: 0x060002A6 RID: 678 RVA: 0x0001DE00 File Offset: 0x0001C000
  828. public void ManageMapper(string value)
  829. {
  830. if (value != null)
  831. {
  832. value = ModBase.RegexSeek(value, "[0-9a-zA-Z_-]+", 0);
  833. if (value != null && Enumerable.Count<char>(value) > 1 && Operators.CompareString(ModBase.Val(value).ToString(), value, false) != 0 && !value.ContainsF("name", true) && !value.ContainsF("modid", true))
  834. {
  835. if (!this._StrategyRepository.Contains(value))
  836. {
  837. this._StrategyRepository.Add(value);
  838. }
  839. if (this._DefinitionRepository == null)
  840. {
  841. this._DefinitionRepository = value;
  842. }
  843. }
  844. }
  845. }
  846. // Token: 0x060002A7 RID: 679 RVA: 0x00003AE2 File Offset: 0x00001CE2
  847. public string AwakeMapper()
  848. {
  849. if (this.m_ProcRepository == null)
  850. {
  851. this.Load(false);
  852. }
  853. return this.m_ProcRepository;
  854. }
  855. // Token: 0x060002A8 RID: 680 RVA: 0x00003AF9 File Offset: 0x00001CF9
  856. public void FillMapper(string value)
  857. {
  858. if (this.m_ProcRepository == null && value != null && value.StartsWithF("http", false))
  859. {
  860. this.m_ProcRepository = value;
  861. }
  862. }
  863. // Token: 0x060002A9 RID: 681 RVA: 0x00003B1B File Offset: 0x00001D1B
  864. public string NewMapper()
  865. {
  866. if (this._ParserTest == null)
  867. {
  868. this.Load(false);
  869. }
  870. return this._ParserTest;
  871. }
  872. // Token: 0x060002AA RID: 682 RVA: 0x00003B32 File Offset: 0x00001D32
  873. public void ComputeMapper(string value)
  874. {
  875. if (this._ParserTest == null && !string.IsNullOrWhiteSpace(value))
  876. {
  877. this._ParserTest = value;
  878. }
  879. }
  880. // Token: 0x1700002A RID: 42
  881. // (get) Token: 0x060002AB RID: 683 RVA: 0x00003B4B File Offset: 0x00001D4B
  882. public Dictionary<string, string> Dependencies
  883. {
  884. get
  885. {
  886. this.Load(false);
  887. return this.broadcasterTest;
  888. }
  889. }
  890. // Token: 0x060002AC RID: 684 RVA: 0x0001DE88 File Offset: 0x0001C088
  891. private void AddDependency(string ModID, string VersionRequirement = null)
  892. {
  893. if (ModID != null && Enumerable.Count<char>(ModID) >= 2)
  894. {
  895. ModID = ModID.ToLower();
  896. if (Operators.CompareString(ModID, "name", false) != 0 && Operators.CompareString(ModBase.Val(ModID).ToString(), ModID, false) != 0)
  897. {
  898. if (VersionRequirement != null && (VersionRequirement.Contains(".") || VersionRequirement.Contains("-")) && !VersionRequirement.Contains("$"))
  899. {
  900. if (!VersionRequirement.StartsWithF("[", false) && !VersionRequirement.StartsWithF("(", false) && !VersionRequirement.EndsWithF("]", false) && !VersionRequirement.EndsWithF(")", false))
  901. {
  902. VersionRequirement = "[" + VersionRequirement + ",)";
  903. }
  904. }
  905. else
  906. {
  907. VersionRequirement = null;
  908. }
  909. if (this.broadcasterTest.ContainsKey(ModID))
  910. {
  911. if (this.broadcasterTest[ModID] == null)
  912. {
  913. this.broadcasterTest[ModID] = VersionRequirement;
  914. return;
  915. }
  916. }
  917. else
  918. {
  919. this.broadcasterTest.Add(ModID, VersionRequirement);
  920. }
  921. }
  922. }
  923. }
  924. // Token: 0x060002AD RID: 685 RVA: 0x00003B5A File Offset: 0x00001D5A
  925. public bool SortMapper()
  926. {
  927. this.Load(false);
  928. return this.SetupMapper() == null;
  929. }
  930. // Token: 0x060002AE RID: 686 RVA: 0x00003B6C File Offset: 0x00001D6C
  931. public Exception SetupMapper()
  932. {
  933. this.Load(false);
  934. return this._ReaderTest;
  935. }
  936. // Token: 0x060002AF RID: 687 RVA: 0x0001DF8C File Offset: 0x0001C18C
  937. private void Init()
  938. {
  939. this.m_SchemaRepository = null;
  940. this.m_DescriptorRepository = null;
  941. this._PublisherRepository = null;
  942. this._DefinitionRepository = null;
  943. this._StrategyRepository = new List<string>();
  944. this.broadcasterTest = new Dictionary<string, string>();
  945. this.m_FieldTest = false;
  946. this._ReaderTest = null;
  947. this._ConfigTest = false;
  948. this._TestsTest = false;
  949. }
  950. // Token: 0x060002B0 RID: 688 RVA: 0x0001DFE8 File Offset: 0x0001C1E8
  951. public void Load(bool ForceReload = false)
  952. {
  953. if (!this.m_FieldTest || ForceReload)
  954. {
  955. this.Init();
  956. ZipArchive zipArchive = null;
  957. try
  958. {
  959. if (this.Path.Length < 2)
  960. {
  961. throw new FileNotFoundException("错误的 Mod 文件路径(" + (this.Path ?? "null") + ")");
  962. }
  963. if (!File.Exists(this.Path))
  964. {
  965. throw new FileNotFoundException("未找到 Mod 文件(" + this.Path + ")");
  966. }
  967. zipArchive = new ZipArchive(new FileStream(this.Path, FileMode.Open));
  968. this.LookupMetadata(zipArchive);
  969. }
  970. catch (UnauthorizedAccessException ex)
  971. {
  972. ModBase.Log(ex, "Mod 文件由于无权限无法打开(" + this.Path + ")", ModBase.LogLevel.Developer, "出现错误");
  973. this._ReaderTest = new UnauthorizedAccessException("没有读取此文件的权限,请尝试右键以管理员身份运行 PCL", ex);
  974. }
  975. catch (Exception ex2)
  976. {
  977. ModBase.Log(ex2, "Mod 文件无法打开(" + this.Path + ")", ModBase.LogLevel.Developer, "出现错误");
  978. this._ReaderTest = ex2;
  979. }
  980. finally
  981. {
  982. if (zipArchive != null)
  983. {
  984. zipArchive.Dispose();
  985. }
  986. }
  987. this.m_FieldTest = true;
  988. }
  989. }
  990. // Token: 0x060002B1 RID: 689 RVA: 0x0001E134 File Offset: 0x0001C334
  991. private void LookupMetadata(ZipArchive Jar)
  992. {
  993. checked
  994. {
  995. try
  996. {
  997. ZipArchiveEntry entry = Jar.GetEntry("mcmod.info");
  998. string text = null;
  999. if (entry != null)
  1000. {
  1001. text = ModBase.ReadFile(entry.Open(), null);
  1002. if (text.Length < 15)
  1003. {
  1004. text = null;
  1005. }
  1006. }
  1007. if (text != null)
  1008. {
  1009. object objectValue = RuntimeHelpers.GetObjectValue(ModBase.GetJson(text));
  1010. JObject jobject;
  1011. if (Operators.ConditionalCompareObjectEqual(NewLateBinding.LateGet(objectValue, null, "Type", new object[0], null, null, null), 2, false))
  1012. {
  1013. jobject = (JObject)NewLateBinding.LateIndexGet(objectValue, new object[]
  1014. {
  1015. 0
  1016. }, null);
  1017. }
  1018. else
  1019. {
  1020. jobject = (JObject)NewLateBinding.LateIndexGet(NewLateBinding.LateIndexGet(objectValue, new object[]
  1021. {
  1022. "modList"
  1023. }, null), new object[]
  1024. {
  1025. 0
  1026. }, null);
  1027. }
  1028. this.Name = (string)jobject["name"];
  1029. this.Description = (string)jobject["description"];
  1030. this.Version = (string)jobject["version"];
  1031. this.FillMapper((string)jobject["url"]);
  1032. this.ManageMapper((string)jobject["modid"]);
  1033. JArray jarray = (JArray)jobject["authorList"];
  1034. if (jarray != null)
  1035. {
  1036. List<string> list = new List<string>();
  1037. try
  1038. {
  1039. foreach (JToken jtoken in jarray)
  1040. {
  1041. list.Add(jtoken.ToString());
  1042. }
  1043. }
  1044. finally
  1045. {
  1046. IEnumerator<JToken> enumerator;
  1047. if (enumerator != null)
  1048. {
  1049. enumerator.Dispose();
  1050. }
  1051. }
  1052. if (Enumerable.Any<string>(list))
  1053. {
  1054. this.ComputeMapper(list.Join(", "));
  1055. }
  1056. }
  1057. JArray jarray2 = (JArray)jobject["requiredMods"];
  1058. if (jarray2 != null)
  1059. {
  1060. try
  1061. {
  1062. foreach (JToken jtoken2 in jarray2)
  1063. {
  1064. string text2 = (string)jtoken2;
  1065. if (!string.IsNullOrEmpty(text2))
  1066. {
  1067. text2 = text2.Substring(text2.IndexOfF(":", false) + 1);
  1068. if (text2.Contains("@"))
  1069. {
  1070. this.AddDependency(text2.Split("@")[0], text2.Split("@")[1]);
  1071. }
  1072. else
  1073. {
  1074. this.AddDependency(text2, null);
  1075. }
  1076. }
  1077. }
  1078. }
  1079. finally
  1080. {
  1081. IEnumerator<JToken> enumerator2;
  1082. if (enumerator2 != null)
  1083. {
  1084. enumerator2.Dispose();
  1085. }
  1086. }
  1087. }
  1088. jarray2 = (JArray)jobject["dependancies"];
  1089. if (jarray2 != null)
  1090. {
  1091. try
  1092. {
  1093. foreach (JToken jtoken3 in jarray2)
  1094. {
  1095. string text3 = (string)jtoken3;
  1096. if (!string.IsNullOrEmpty(text3))
  1097. {
  1098. text3 = text3.Substring(text3.IndexOfF(":", false) + 1);
  1099. if (text3.Contains("@"))
  1100. {
  1101. this.AddDependency(text3.Split("@")[0], text3.Split("@")[1]);
  1102. }
  1103. else
  1104. {
  1105. this.AddDependency(text3, null);
  1106. }
  1107. }
  1108. }
  1109. }
  1110. finally
  1111. {
  1112. IEnumerator<JToken> enumerator3;
  1113. if (enumerator3 != null)
  1114. {
  1115. enumerator3.Dispose();
  1116. }
  1117. }
  1118. }
  1119. }
  1120. }
  1121. catch (Exception ex)
  1122. {
  1123. ModBase.Log(ex, "读取 mcmod.info 时出现未知错误(" + this.Path + ")", ModBase.LogLevel.Developer, "出现错误");
  1124. }
  1125. try
  1126. {
  1127. ZipArchiveEntry entry2 = Jar.GetEntry("fabric.mod.json");
  1128. string text4 = null;
  1129. if (entry2 != null)
  1130. {
  1131. text4 = ModBase.ReadFile(entry2.Open(), Encoding.UTF8);
  1132. if (!text4.Contains("schemaVersion"))
  1133. {
  1134. text4 = null;
  1135. }
  1136. }
  1137. if (text4 != null)
  1138. {
  1139. JObject jobject2 = (JObject)ModBase.GetJson(text4);
  1140. if (jobject2.ContainsKey("name"))
  1141. {
  1142. this.Name = (string)jobject2["name"];
  1143. }
  1144. if (jobject2.ContainsKey("version"))
  1145. {
  1146. this.Version = (string)jobject2["version"];
  1147. }
  1148. if (jobject2.ContainsKey("description"))
  1149. {
  1150. this.Description = (string)jobject2["description"];
  1151. }
  1152. if (jobject2.ContainsKey("id"))
  1153. {
  1154. this.ManageMapper((string)jobject2["id"]);
  1155. }
  1156. if (jobject2.ContainsKey("contact"))
  1157. {
  1158. this.FillMapper((string)(jobject2["contact"]["homepage"] ?? ""));
  1159. }
  1160. JArray jarray3 = (JArray)jobject2["authors"];
  1161. if (jarray3 != null)
  1162. {
  1163. List<string> list2 = new List<string>();
  1164. try
  1165. {
  1166. foreach (JToken jtoken4 in jarray3)
  1167. {
  1168. list2.Add(jtoken4.ToString());
  1169. }
  1170. }
  1171. finally
  1172. {
  1173. IEnumerator<JToken> enumerator4;
  1174. if (enumerator4 != null)
  1175. {
  1176. enumerator4.Dispose();
  1177. }
  1178. }
  1179. if (Enumerable.Any<string>(list2))
  1180. {
  1181. this.ComputeMapper(list2.Join(", "));
  1182. }
  1183. }
  1184. goto IL_F7F;
  1185. }
  1186. }
  1187. catch (Exception ex2)
  1188. {
  1189. ModBase.Log(ex2, "读取 fabric.mod.json 时出现未知错误(" + this.Path + ")", ModBase.LogLevel.Developer, "出现错误");
  1190. }
  1191. try
  1192. {
  1193. ZipArchiveEntry entry3 = Jar.GetEntry("META-INF/mods.toml");
  1194. string text5 = null;
  1195. if (entry3 != null)
  1196. {
  1197. text5 = ModBase.ReadFile(entry3.Open(), null);
  1198. if (text5.Length < 15)
  1199. {
  1200. text5 = null;
  1201. }
  1202. }
  1203. if (text5 != null)
  1204. {
  1205. List<string> list3 = new List<string>();
  1206. foreach (string text6 in text5.Replace("\r\n", "\n").Replace("\r", "\n").Split("\n"))
  1207. {
  1208. if (!text6.StartsWithF("#", false))
  1209. {
  1210. if (text6.Contains("#"))
  1211. {
  1212. text6 = text6.Substring(0, text6.IndexOfF("#", false));
  1213. }
  1214. text6 = text6.Trim(new char[]
  1215. {
  1216. ' ',
  1217. '\t',
  1218. '\u3000'
  1219. });
  1220. if (Enumerable.Any<char>(text6))
  1221. {
  1222. list3.Add(text6);
  1223. }
  1224. }
  1225. }
  1226. List<KeyValuePair<string, Dictionary<string, object>>> list4 = new List<KeyValuePair<string, Dictionary<string, object>>>
  1227. {
  1228. new KeyValuePair<string, Dictionary<string, object>>("", new Dictionary<string, object>())
  1229. };
  1230. int num = list3.Count - 1;
  1231. for (int j = 0; j <= num; j++)
  1232. {
  1233. string text7 = list3[j];
  1234. if (text7.StartsWithF("[", false) && text7.EndsWithF("]", false))
  1235. {
  1236. string key = text7.Trim("[]".ToCharArray());
  1237. list4.Add(new KeyValuePair<string, Dictionary<string, object>>(key, new Dictionary<string, object>()));
  1238. }
  1239. else
  1240. {
  1241. if (!text7.Contains("="))
  1242. {
  1243. goto IL_B3E;
  1244. }
  1245. string key2 = text7.Substring(0, text7.IndexOfF("=", false)).TrimEnd(new char[]
  1246. {
  1247. ' ',
  1248. '\t',
  1249. '\u3000'
  1250. });
  1251. string text8 = text7.Substring(text7.IndexOfF("=", false) + 1).TrimStart(new char[]
  1252. {
  1253. ' ',
  1254. '\t',
  1255. '\u3000'
  1256. });
  1257. object obj;
  1258. if (text8.StartsWithF("\"", false) && text8.EndsWithF("\"", false))
  1259. {
  1260. obj = text8.Trim(new char[]
  1261. {
  1262. '"'
  1263. });
  1264. }
  1265. else if (text8.StartsWithF("'''", false))
  1266. {
  1267. List<string> list5 = new List<string>
  1268. {
  1269. text8.TrimStart(new char[]
  1270. {
  1271. '\''
  1272. })
  1273. };
  1274. if (list5[0].EndsWithF("'''", false))
  1275. {
  1276. list5[0] = list5[0].TrimEnd(new char[]
  1277. {
  1278. '\''
  1279. });
  1280. }
  1281. else
  1282. {
  1283. while (j < list3.Count - 1)
  1284. {
  1285. j++;
  1286. string text9 = list3[j];
  1287. if (text9.EndsWithF("'''", false))
  1288. {
  1289. list5.Add(text9.TrimEnd(new char[]
  1290. {
  1291. '\''
  1292. }));
  1293. break;
  1294. }
  1295. list5.Add(text9);
  1296. }
  1297. }
  1298. obj = list5.Join("\n").Trim(new char[]
  1299. {
  1300. '\n'
  1301. }).Replace("\n", "\r\n");
  1302. }
  1303. else if (Operators.CompareString(text8.ToLower(), "true", false) != 0 && Operators.CompareString(text8.ToLower(), "false", false) != 0)
  1304. {
  1305. if (Operators.CompareString(ModBase.Val(text8).ToString(), text8, false) == 0)
  1306. {
  1307. obj = ModBase.Val(text8);
  1308. }
  1309. else
  1310. {
  1311. obj = text8;
  1312. }
  1313. }
  1314. else
  1315. {
  1316. obj = (Operators.CompareString(text8.ToLower(), "true", false) == 0);
  1317. }
  1318. Enumerable.Last<KeyValuePair<string, Dictionary<string, object>>>(list4).Value[key2] = RuntimeHelpers.GetObjectValue(obj);
  1319. }
  1320. }
  1321. Dictionary<string, object> dictionary = null;
  1322. try
  1323. {
  1324. foreach (KeyValuePair<string, Dictionary<string, object>> keyValuePair in list4)
  1325. {
  1326. if (Operators.CompareString(keyValuePair.Key, "mods", false) == 0)
  1327. {
  1328. dictionary = keyValuePair.Value;
  1329. break;
  1330. }
  1331. }
  1332. }
  1333. finally
  1334. {
  1335. List<KeyValuePair<string, Dictionary<string, object>>>.Enumerator enumerator5;
  1336. ((IDisposable)enumerator5).Dispose();
  1337. }
  1338. if (dictionary != null && dictionary.ContainsKey("modId"))
  1339. {
  1340. this.ManageMapper(Conversions.ToString(dictionary["modId"]));
  1341. if (this._DefinitionRepository != null)
  1342. {
  1343. if (dictionary.ContainsKey("displayName"))
  1344. {
  1345. this.Name = Conversions.ToString(dictionary["displayName"]);
  1346. }
  1347. if (dictionary.ContainsKey("description"))
  1348. {
  1349. this.Description = Conversions.ToString(dictionary["description"]);
  1350. }
  1351. if (dictionary.ContainsKey("version"))
  1352. {
  1353. this.Version = Conversions.ToString(dictionary["version"]);
  1354. }
  1355. if (list4[0].Value.ContainsKey("displayURL"))
  1356. {
  1357. this.FillMapper(Conversions.ToString(list4[0].Value["displayURL"]));
  1358. }
  1359. if (list4[0].Value.ContainsKey("authors"))
  1360. {
  1361. this.ComputeMapper(Conversions.ToString(list4[0].Value["authors"]));
  1362. }
  1363. try
  1364. {
  1365. foreach (KeyValuePair<string, Dictionary<string, object>> keyValuePair2 in list4)
  1366. {
  1367. if (Operators.CompareString(keyValuePair2.Key.ToLower(), string.Format("dependencies.{0}", this.LoginMapper().ToLower()), false) == 0)
  1368. {
  1369. Dictionary<string, object> value = keyValuePair2.Value;
  1370. if (Conversions.ToBoolean(value.ContainsKey("modId") && value.ContainsKey("mandatory") && Conversions.ToBoolean(value["mandatory"]) && value.ContainsKey("side") && Operators.CompareString(value["side"].ToString().ToLower(), "server", false) != 0))
  1371. {
  1372. this.AddDependency(Conversions.ToString(value["modId"]), Conversions.ToString(value.ContainsKey("versionRange") ? value["versionRange"] : null));
  1373. }
  1374. }
  1375. }
  1376. }
  1377. finally
  1378. {
  1379. List<KeyValuePair<string, Dictionary<string, object>>>.Enumerator enumerator6;
  1380. ((IDisposable)enumerator6).Dispose();
  1381. }
  1382. goto IL_F7F;
  1383. }
  1384. }
  1385. }
  1386. }
  1387. catch (Exception ex3)
  1388. {
  1389. ModBase.Log(ex3, "读取 mods.toml 时出现未知错误(" + this.Path + ")", ModBase.LogLevel.Developer, "出现错误");
  1390. }
  1391. IL_B3E:
  1392. try
  1393. {
  1394. ZipArchiveEntry entry4 = Jar.GetEntry("META-INF/fml_cache_annotation.json");
  1395. string text10 = null;
  1396. if (entry4 != null)
  1397. {
  1398. text10 = ModBase.ReadFile(entry4.Open(), Encoding.UTF8);
  1399. if (!text10.Contains("Lnet/minecraftforge/fml/common/Mod;"))
  1400. {
  1401. text10 = null;
  1402. }
  1403. }
  1404. if (text10 != null)
  1405. {
  1406. JObject jobject3 = (JObject)ModBase.GetJson(text10);
  1407. JObject jobject4 = null;
  1408. try
  1409. {
  1410. foreach (KeyValuePair<string, JToken> keyValuePair3 in jobject3)
  1411. {
  1412. JArray jarray4 = (JArray)keyValuePair3.Value["annotations"];
  1413. if (jarray4 != null)
  1414. {
  1415. try
  1416. {
  1417. foreach (JToken jtoken5 in jarray4)
  1418. {
  1419. if (Operators.CompareString((string)(jtoken5["name"] ?? ""), "Lnet/minecraftforge/fml/common/Mod;", false) == 0)
  1420. {
  1421. jobject4 = (JObject)jtoken5["values"];
  1422. goto IL_C4F;
  1423. }
  1424. }
  1425. }
  1426. finally
  1427. {
  1428. IEnumerator<JToken> enumerator8;
  1429. if (enumerator8 != null)
  1430. {
  1431. enumerator8.Dispose();
  1432. }
  1433. }
  1434. }
  1435. }
  1436. }
  1437. finally
  1438. {
  1439. IEnumerator<KeyValuePair<string, JToken>> enumerator7;
  1440. if (enumerator7 != null)
  1441. {
  1442. enumerator7.Dispose();
  1443. }
  1444. }
  1445. goto IL_F7F;
  1446. IL_C4F:
  1447. if (jobject4.ContainsKey("useMetadata") && Operators.CompareString((jobject4["useMetadata"]["value"] ?? "").ToString().ToLower(), "true", false) == 0)
  1448. {
  1449. string text11 = (string)jobject4["modid"]["value"];
  1450. if (text11 != null)
  1451. {
  1452. text11 = ModBase.RegexSeek(text11.ToLower(), "[0-9a-z_]+", 0);
  1453. if (text11 != null && Operators.CompareString(text11.ToLower(), "name", false) != 0 && Enumerable.Count<char>(text11) > 1 && Operators.CompareString(ModBase.Val(text11).ToString(), text11, false) != 0 && !this._StrategyRepository.Contains(text11))
  1454. {
  1455. this._StrategyRepository.Add(text11);
  1456. }
  1457. }
  1458. }
  1459. else
  1460. {
  1461. if (jobject4.ContainsKey("name"))
  1462. {
  1463. this.Name = (string)jobject4["name"]["value"];
  1464. }
  1465. if (jobject4.ContainsKey("version"))
  1466. {
  1467. this.Version = (string)jobject4["version"]["value"];
  1468. }
  1469. if (jobject4.ContainsKey("modid"))
  1470. {
  1471. this.ManageMapper((string)jobject4["modid"]["value"]);
  1472. }
  1473. if (!jobject4.ContainsKey("serverSideOnly") || !jobject4["serverSideOnly"]["value"].ToObject<bool>())
  1474. {
  1475. JToken jtoken6;
  1476. if (jobject4["acceptedMinecraftVersions"] == null)
  1477. {
  1478. if ((jtoken6 = "") != null)
  1479. {
  1480. goto IL_E32;
  1481. }
  1482. }
  1483. else if ((jtoken6 = jobject4["acceptedMinecraftVersions"]["value"]) != null)
  1484. {
  1485. goto IL_E32;
  1486. }
  1487. jtoken6 = "";
  1488. IL_E32:
  1489. string text12 = (string)jtoken6;
  1490. if (Operators.CompareString(text12, "", false) != 0)
  1491. {
  1492. this.AddDependency("minecraft", text12);
  1493. }
  1494. JToken jtoken7;
  1495. if (jobject4["dependencies"] == null)
  1496. {
  1497. if ((jtoken7 = "") != null)
  1498. {
  1499. goto IL_E97;
  1500. }
  1501. }
  1502. else if ((jtoken7 = jobject4["dependencies"]["value"]) != null)
  1503. {
  1504. goto IL_E97;
  1505. }
  1506. jtoken7 = "";
  1507. IL_E97:
  1508. string text13 = (string)jtoken7;
  1509. if (Operators.CompareString(text13, "", false) != 0)
  1510. {
  1511. foreach (string text14 in text13.Split(";"))
  1512. {
  1513. if (Operators.CompareString(text14, "", false) != 0 && text14.StartsWithF("required-", false))
  1514. {
  1515. text14 = text14.Substring(text14.IndexOfF(":", false) + 1);
  1516. if (text14.Contains("@"))
  1517. {
  1518. this.AddDependency(text14.Split("@")[0], text14.Split("@")[1]);
  1519. }
  1520. else
  1521. {
  1522. this.AddDependency(text14, null);
  1523. }
  1524. }
  1525. }
  1526. }
  1527. }
  1528. }
  1529. }
  1530. }
  1531. catch (Exception ex4)
  1532. {
  1533. ModBase.Log(ex4, "读取 fml_cache_annotation.json 时出现未知错误(" + this.Path + ")", ModBase.LogLevel.Developer, "出现错误");
  1534. }
  1535. IL_F7F:
  1536. if (Operators.CompareString(this._PublisherRepository, "version", false) == 0)
  1537. {
  1538. try
  1539. {
  1540. ZipArchiveEntry entry5 = Jar.GetEntry("META-INF/MANIFEST.MF");
  1541. if (entry5 != null)
  1542. {
  1543. string text15 = ModBase.ReadFile(entry5.Open(), null).Replace(" :", ":").Replace(": ", ":");
  1544. if (text15.Contains("Implementation-Version:"))
  1545. {
  1546. text15 = text15.Substring(text15.IndexOfF("Implementation-Version:", false) + Enumerable.Count<char>("Implementation-Version:"));
  1547. text15 = text15.Substring(0, text15.IndexOfAny("\r\n".ToCharArray())).Trim();
  1548. this.Version = text15;
  1549. }
  1550. }
  1551. }
  1552. catch (Exception ex5)
  1553. {
  1554. ModBase.Log("获取 META-INF 中的版本信息失败(" + this.Path + ")", ModBase.LogLevel.Developer, "出现错误");
  1555. this.Version = null;
  1556. }
  1557. }
  1558. if (this._PublisherRepository != null && !this._PublisherRepository.Contains(".") && !this._PublisherRepository.Contains("-"))
  1559. {
  1560. this.Version = null;
  1561. }
  1562. }
  1563. }
  1564. // Token: 0x060002B2 RID: 690 RVA: 0x0001F314 File Offset: 0x0001D514
  1565. [CompilerGenerated]
  1566. public void ViewMapper(ModMod.McMod.OnCompUpdateEventHandler obj)
  1567. {
  1568. ModMod.McMod.OnCompUpdateEventHandler onCompUpdateEventHandler = this.mapperTest;
  1569. ModMod.McMod.OnCompUpdateEventHandler onCompUpdateEventHandler2;
  1570. do
  1571. {
  1572. onCompUpdateEventHandler2 = onCompUpdateEventHandler;
  1573. ModMod.McMod.OnCompUpdateEventHandler value = (ModMod.McMod.OnCompUpdateEventHandler)Delegate.Combine(onCompUpdateEventHandler2, obj);
  1574. onCompUpdateEventHandler = Interlocked.CompareExchange<ModMod.McMod.OnCompUpdateEventHandler>(ref this.mapperTest, value, onCompUpdateEventHandler2);
  1575. }
  1576. while (onCompUpdateEventHandler != onCompUpdateEventHandler2);
  1577. }
  1578. // Token: 0x060002B3 RID: 691 RVA: 0x0001F34C File Offset: 0x0001D54C
  1579. [CompilerGenerated]
  1580. public void PushMapper(ModMod.McMod.OnCompUpdateEventHandler obj)
  1581. {
  1582. ModMod.McMod.OnCompUpdateEventHandler onCompUpdateEventHandler = this.mapperTest;
  1583. ModMod.McMod.OnCompUpdateEventHandler onCompUpdateEventHandler2;
  1584. do
  1585. {
  1586. onCompUpdateEventHandler2 = onCompUpdateEventHandler;
  1587. ModMod.McMod.OnCompUpdateEventHandler value = (ModMod.McMod.OnCompUpdateEventHandler)Delegate.Remove(onCompUpdateEventHandler2, obj);
  1588. onCompUpdateEventHandler = Interlocked.CompareExchange<ModMod.McMod.OnCompUpdateEventHandler>(ref this.mapperTest, value, onCompUpdateEventHandler2);
  1589. }
  1590. while (onCompUpdateEventHandler != onCompUpdateEventHandler2);
  1591. }
  1592. // Token: 0x1700002B RID: 43
  1593. // (get) Token: 0x060002B4 RID: 692 RVA: 0x00003B7B File Offset: 0x00001D7B
  1594. // (set) Token: 0x060002B5 RID: 693 RVA: 0x0001F384 File Offset: 0x0001D584
  1595. public ModComp.CompProject Comp
  1596. {
  1597. get
  1598. {
  1599. return this._ThreadTest;
  1600. }
  1601. set
  1602. {
  1603. this._ThreadTest = value;
  1604. ModMod.McMod.OnCompUpdateEventHandler onCompUpdateEventHandler = this.mapperTest;
  1605. if (onCompUpdateEventHandler != null)
  1606. {
  1607. onCompUpdateEventHandler(this);
  1608. }
  1609. }
  1610. }
  1611. // Token: 0x1700002C RID: 44
  1612. // (get) Token: 0x060002B6 RID: 694 RVA: 0x00003B83 File Offset: 0x00001D83
  1613. // (set) Token: 0x060002B7 RID: 695 RVA: 0x0001F3AC File Offset: 0x0001D5AC
  1614. public ModComp.CompFile UpdateFile
  1615. {
  1616. get
  1617. {
  1618. return this.m_ComposerTest;
  1619. }
  1620. set
  1621. {
  1622. this.m_ComposerTest = value;
  1623. ModMod.McMod.OnCompUpdateEventHandler onCompUpdateEventHandler = this.mapperTest;
  1624. if (onCompUpdateEventHandler != null)
  1625. {
  1626. onCompUpdateEventHandler(this);
  1627. }
  1628. }
  1629. }
  1630. // Token: 0x060002B8 RID: 696 RVA: 0x0001F3D4 File Offset: 0x0001D5D4
  1631. public JObject ToJson()
  1632. {
  1633. JObject jobject = new JObject();
  1634. if (this.Comp != null)
  1635. {
  1636. jobject.Add("Comp", this.Comp.ToJson());
  1637. }
  1638. jobject.Add("ChangelogUrls", new JArray(this.m_IteratorTest));
  1639. jobject.Add("CompLoaded", this.m_RepositoryTest);
  1640. if (this._PropertyTest != null)
  1641. {
  1642. jobject.Add("CompFile", this._PropertyTest.ToJson());
  1643. }
  1644. if (this.UpdateFile != null)
  1645. {
  1646. jobject.Add("UpdateFile", this.UpdateFile.ToJson());
  1647. }
  1648. return jobject;
  1649. }
  1650. // Token: 0x060002B9 RID: 697 RVA: 0x0001F470 File Offset: 0x0001D670
  1651. public void FromJson(JObject Json)
  1652. {
  1653. this.m_RepositoryTest = (bool)Json["CompLoaded"];
  1654. if (Json.ContainsKey("Comp"))
  1655. {
  1656. this.Comp = new ModComp.CompProject((JObject)Json["Comp"]);
  1657. }
  1658. if (Json.ContainsKey("ChangelogUrls"))
  1659. {
  1660. this.m_IteratorTest = Json["ChangelogUrls"].ToObject<List<string>>();
  1661. }
  1662. if (Json.ContainsKey("CompFile"))
  1663. {
  1664. this._PropertyTest = new ModComp.CompFile((JObject)Json["CompFile"], ModComp.CompType.Mod);
  1665. }
  1666. if (Json.ContainsKey("UpdateFile"))
  1667. {
  1668. this.UpdateFile = new ModComp.CompFile((JObject)Json["UpdateFile"], ModComp.CompType.Mod);
  1669. }
  1670. }
  1671. // Token: 0x060002BA RID: 698 RVA: 0x00003B8B File Offset: 0x00001D8B
  1672. public bool SelectMapper()
  1673. {
  1674. return Conversions.ToBoolean(Conversions.ToBoolean(Operators.NotObject(ModBase.m_IdentifierRepository.Get("UiHiddenFunctionModUpdate", null))) && Enumerable.Any<string>(this.m_IteratorTest));
  1675. }
  1676. // Token: 0x060002BB RID: 699 RVA: 0x0001F530 File Offset: 0x0001D730
  1677. public uint LogoutMapper()
  1678. {
  1679. checked
  1680. {
  1681. if (this.m_TestTest == null)
  1682. {
  1683. FileInfo fileInfo = new FileInfo(this.Path);
  1684. string key = Conversions.ToString(ModBase.GetHash(string.Format("{0}-{1}-{2}-C", this.CustomizeTests(), fileInfo.LastWriteTime.ToLongTimeString(), fileInfo.Length)));
  1685. string text = ModBase.ReadIni(ModBase.m_DecoratorRepository + "Cache\\ModHash.ini", key, "");
  1686. if (Operators.CompareString(text, "", false) != 0 && ModBase.RegexCheck(text, "^\\d+$", 0))
  1687. {
  1688. this.m_TestTest = new uint?(Conversions.ToUInteger(text));
  1689. return this.m_TestTest.Value;
  1690. }
  1691. List<byte> list = new List<byte>();
  1692. foreach (byte b in ModBase.ReadFileBytes(this.Path, null))
  1693. {
  1694. if (b != 9 && b != 10 && b != 13 && b != 32)
  1695. {
  1696. list.Add(b);
  1697. }
  1698. }
  1699. int count = list.Count;
  1700. uint num = (uint)(1 ^ count);
  1701. int num2 = count - 4;
  1702. int j;
  1703. for (j = 0; j <= num2; j += 4)
  1704. {
  1705. uint num3 = (uint)((int)list[j] | (int)list[j + 1] << 8 | (int)list[j + 2] << 16 | (int)list[j + 3] << 24);
  1706. num3 = (uint)(unchecked((ulong)num3) * 1540483477UL & 4294967295UL);
  1707. num3 ^= num3 >> 24;
  1708. num3 = (uint)(unchecked((ulong)num3) * 1540483477UL & 4294967295UL);
  1709. num = (uint)(unchecked((ulong)num) * 1540483477UL & 4294967295UL);
  1710. num ^= num3;
  1711. }
  1712. switch (count - j)
  1713. {
  1714. case 1:
  1715. num ^= (uint)list[j];
  1716. num = (uint)(unchecked((ulong)num) * 1540483477UL & 4294967295UL);
  1717. break;
  1718. case 2:
  1719. num ^= (uint)((int)list[j] | (int)list[j + 1] << 8);
  1720. num = (uint)(unchecked((ulong)num) * 1540483477UL & 4294967295UL);
  1721. break;
  1722. case 3:
  1723. num ^= (uint)((int)list[j] | (int)list[j + 1] << 8);
  1724. num ^= (uint)((uint)list[j + 2] << 16);
  1725. num = (uint)(unchecked((ulong)num) * 1540483477UL & 4294967295UL);
  1726. break;
  1727. }
  1728. num ^= num >> 13;
  1729. num = (uint)(unchecked((ulong)num) * 1540483477UL & 4294967295UL);
  1730. num ^= num >> 15;
  1731. this.m_TestTest = new uint?(num);
  1732. ModBase.WriteIni(ModBase.m_DecoratorRepository + "Cache\\ModHash.ini", key, num.ToString());
  1733. }
  1734. return this.m_TestTest.Value;
  1735. }
  1736. }
  1737. // Token: 0x060002BC RID: 700 RVA: 0x0001F830 File Offset: 0x0001DA30
  1738. public string ReflectMapper()
  1739. {
  1740. if (this.m_MapTest == null)
  1741. {
  1742. FileInfo fileInfo = new FileInfo(this.Path);
  1743. string key = Conversions.ToString(ModBase.GetHash(string.Format("{0}-{1}-{2}-M", this.CustomizeTests(), fileInfo.LastWriteTime.ToLongTimeString(), fileInfo.Length)));
  1744. string text = ModBase.ReadIni(ModBase.m_DecoratorRepository + "Cache\\ModHash.ini", key, "");
  1745. if (Operators.CompareString(text, "", false) != 0)
  1746. {
  1747. this.m_MapTest = text;
  1748. return this.m_MapTest;
  1749. }
  1750. this.m_MapTest = ModBase.smethod_1(this.Path);
  1751. ModBase.WriteIni(ModBase.m_DecoratorRepository + "Cache\\ModHash.ini", key, this.m_MapTest);
  1752. }
  1753. return this.m_MapTest;
  1754. }
  1755. // Token: 0x060002BD RID: 701 RVA: 0x00003BC1 File Offset: 0x00001DC1
  1756. public override string ToString()
  1757. {
  1758. return string.Format("{0} - {1}", this.State, this.Path);
  1759. }
  1760. // Token: 0x060002BE RID: 702 RVA: 0x0001F8F8 File Offset: 0x0001DAF8
  1761. public override bool Equals(object obj)
  1762. {
  1763. ModMod.McMod mcMod = obj as ModMod.McMod;
  1764. return mcMod != null && Operators.CompareString(this.Path, mcMod.Path, false) == 0;
  1765. }
  1766. // Token: 0x060002BF RID: 703 RVA: 0x0001F928 File Offset: 0x0001DB28
  1767. public bool IsPresetMod()
  1768. {
  1769. return !Enumerable.Any<KeyValuePair<string, string>>(this.Dependencies) && this.Name != null && (this.Name.ToLower().Contains("core") || this.Name.ToLower().Contains("lib"));
  1770. }
  1771. // Token: 0x060002C0 RID: 704 RVA: 0x0001F97C File Offset: 0x0001DB7C
  1772. public static object IsModFile(string Path)
  1773. {
  1774. object result;
  1775. if (Path != null && Path.Contains("."))
  1776. {
  1777. Path = Path.ToLower();
  1778. if (!Path.EndsWithF(".jar", true) && !Path.EndsWithF(".zip", true) && !Path.EndsWithF(".litemod", true) && !Path.EndsWithF(".jar.disabled", true) && !Path.EndsWithF(".zip.disabled", true) && !Path.EndsWithF(".litemod.disabled", true) && !Path.EndsWithF(".jar.old", true) && !Path.EndsWithF(".zip.old", true) && !Path.EndsWithF(".litemod.old", true))
  1779. {
  1780. result = false;
  1781. }
  1782. else
  1783. {
  1784. result = true;
  1785. }
  1786. }
  1787. else
  1788. {
  1789. result = false;
  1790. }
  1791. return result;
  1792. }
  1793. // Token: 0x04000187 RID: 391
  1794. public readonly string Path;
  1795. // Token: 0x04000188 RID: 392
  1796. private string m_SchemaRepository;
  1797. // Token: 0x04000189 RID: 393
  1798. private string m_DescriptorRepository;
  1799. // Token: 0x0400018A RID: 394
  1800. public string _PublisherRepository;
  1801. // Token: 0x0400018B RID: 395
  1802. private string _DefinitionRepository;
  1803. // Token: 0x0400018C RID: 396
  1804. public List<string> _StrategyRepository;
  1805. // Token: 0x0400018D RID: 397
  1806. private string m_ProcRepository;
  1807. // Token: 0x0400018E RID: 398
  1808. private string _ParserTest;
  1809. // Token: 0x0400018F RID: 399
  1810. private Dictionary<string, string> broadcasterTest;
  1811. // Token: 0x04000190 RID: 400
  1812. private bool m_FieldTest;
  1813. // Token: 0x04000191 RID: 401
  1814. private Exception _ReaderTest;
  1815. // Token: 0x04000192 RID: 402
  1816. private bool _ClientTest;
  1817. // Token: 0x04000193 RID: 403
  1818. private bool _ConfigTest;
  1819. // Token: 0x04000194 RID: 404
  1820. private bool _TestsTest;
  1821. // Token: 0x04000195 RID: 405
  1822. [CompilerGenerated]
  1823. private ModMod.McMod.OnCompUpdateEventHandler mapperTest;
  1824. // Token: 0x04000196 RID: 406
  1825. private ModComp.CompProject _ThreadTest;
  1826. // Token: 0x04000197 RID: 407
  1827. public ModComp.CompFile _PropertyTest;
  1828. // Token: 0x04000198 RID: 408
  1829. private ModComp.CompFile m_ComposerTest;
  1830. // Token: 0x04000199 RID: 409
  1831. public List<string> m_IteratorTest;
  1832. // Token: 0x0400019A RID: 410
  1833. public bool m_RepositoryTest;
  1834. // Token: 0x0400019B RID: 411
  1835. private uint? m_TestTest;
  1836. // Token: 0x0400019C RID: 412
  1837. private string m_MapTest;
  1838. // Token: 0x02000070 RID: 112
  1839. public enum McModState
  1840. {
  1841. // Token: 0x0400019E RID: 414
  1842. Fine,
  1843. // Token: 0x0400019F RID: 415
  1844. Disabled,
  1845. // Token: 0x040001A0 RID: 416
  1846. Unavailable
  1847. }
  1848. // Token: 0x02000071 RID: 113
  1849. // (Invoke) Token: 0x060002C5 RID: 709
  1850. public delegate void OnCompUpdateEventHandler(ModMod.McMod sender);
  1851. }
  1852. }
  1853. }