codexLog instanceof AnalysableLog) { return null; } if (!$this->codexLog instanceof VanillaLog) { return null; } $analysis = $this->codexLog->analyse(); /** * @var ?Information $version */ $version = $analysis->getFilteredInsights(VanillaVersionInformation::class)[0] ?? null; if (!$version) { return null; } $version = $version->getValue(); try { $map = $this->getObfuscationMap($version); } catch (Exception) { $map = null; } if ($map === null) { return null; } $obfuscatedContent = new ObfuscatedString($this->codexLog->getLogFile()->getContent(), $map); if ($content = $obfuscatedContent->getMappedContent()) { return $content; } return null; } /** * Get the obfuscation map matching this log * * @param $version * @return ObfuscationMap|null * @throws Exception */ protected function getObfuscationMap($version): ?ObfuscationMap { if (in_array(get_class($this->codexLog), [ VanillaServerLog::class, VanillaClientLog::class, VanillaCrashReportLog::class, VanillaNetworkProtocolErrorReportLog::class ])) { $urlCache = new CacheEntry("sherlock:vanilla:$version:client"); $mapURL = $urlCache->get(); if (!$mapURL) { $mapURL = new LauncherMetaMapLocator($version, "client")->findMappingURL(); if (!$mapURL) { return null; } $urlCache->set($mapURL, 30 * 24 * 60 * 60); } try { $mapCache = new CacheEntry("sherlock:$mapURL"); if ($mapContent = $mapCache->get()) { $map = new VanillaObfuscationMap($mapContent); } else { $map = new URLVanillaObfuscationMap($mapURL); $mapCache->set($map->getContent()); } } catch (Exception) { } return $map ?? null; } if ($this->codexLog instanceof FabricLog) { $urlCache = new CacheEntry("sherlock:yarn:$version:server"); $mapURL = $urlCache->get(); if (!$mapURL) { $mapURL = new FabricMavenMapLocator($version)->findMappingURL(); if (!$mapURL) { return null; } $urlCache->set($mapURL, 24 * 60 * 60); } try { $mapCache = new CacheEntry("sherlock:$mapURL"); if ($mapContent = $mapCache->get()) { $map = new YarnMap($mapContent); } else { $map = new GZURLYarnMap($mapURL); $mapCache->set($map->getContent()); } } catch (Exception) { } return $map ?? null; } return null; } }