Add world decrypt // and package addons to .mcaddon

This commit is contained in:
Li 2025-01-21 22:58:26 +13:00
parent a441bfe929
commit b67526b2cc
15 changed files with 565 additions and 125 deletions

View file

@ -4,6 +4,7 @@ using System.Linq;
using Newtonsoft.Json;
using System.IO;
using System.Text;
using Newtonsoft.Json.Linq;
namespace McCrypt
{
@ -43,6 +44,66 @@ namespace McCrypt
string signaturesJsonFile = Path.Combine(basePath, "signatures.json");
File.WriteAllText(signaturesJsonFile, signatureJson);
}
public static string ReadType(string manifestFile)
{
string manifestStr = File.ReadAllText(manifestFile);
dynamic manifestData = JsonConvert.DeserializeObject(manifestStr);
if(manifestData.modules != null)
{
if(manifestData.modules.Count >= 1)
{
return manifestData.modules[0].type;
}
}
return Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(manifestFile)));
}
public static string ReadProductType(string manifestFile)
{
string manifestStr = File.ReadAllText(manifestFile);
dynamic manifestData = JsonConvert.DeserializeObject(manifestStr);
if (manifestData.metadata != null)
{
if (manifestData.metadata.product_type != null)
{
return manifestData.metadata.product_type;
}
}
return null;
}
public static string[] ReadWorldPackList(string packListFile)
{
List<string> depUuidList = new List<string>();
string packStr = File.ReadAllText(packListFile);
dynamic packListData = JsonConvert.DeserializeObject(packStr);
for (int i = 0; i < packListData.Count; i++)
{
dynamic packData = packListData[i];
if(packData.pack_id != null) depUuidList.Add(packData.pack_id.ToString());
}
return depUuidList.ToArray();
}
public static string[] ReadDependancyUuids(string manifestFile)
{
List<string> depUuidList = new List<string>();
string manifestStr = File.ReadAllText(manifestFile);
dynamic manifestData = JsonConvert.DeserializeObject(manifestStr);
if (manifestData.dependencies != null)
{
for(int i = 0; i < manifestData.dependencies.Count; i++)
{
dynamic manifestDependancy = manifestData.dependencies[i];
if(manifestDependancy.uuid != null)
{
depUuidList.Add(manifestDependancy.uuid.ToString());
}
}
}
return depUuidList.ToArray();
}
public static string ReadName(string manifestFile)
{
string defaultName = Path.GetFileName(Path.GetDirectoryName(manifestFile));