diff --git a/src/utils/DeEarth.ts b/src/utils/DeEarth.ts index 5e3683c..be31b9e 100644 --- a/src/utils/DeEarth.ts +++ b/src/utils/DeEarth.ts @@ -41,7 +41,7 @@ export async function DeEarth(modpath: string, movepath: string) { try { //Modrinth for (let i = 0; i < zip.length; i++) { const e = zip[i] - if (e.entryName == "META-INF/mods.toml") { //Forge,NeoForge + if (isForge(e.entryName)) { //Forge,NeoForge const modid = toml.parse(e.getData().toString('utf-8')).mods[0].modId //const body = await got.get(`https://api.modrinth.com/v2/project/${modid}`, { headers: { "User-Agent": "DeEarth" } }).json() const body = JSON.parse(await FastGot(`https://api.modrinth.com/v2/project/${modid}`)) @@ -61,7 +61,7 @@ export async function DeEarth(modpath: string, movepath: string) { try{//DeEarthPublic for (let i = 0; i < zip.length; i++) { const e = zip[i] - if (e.entryName == "META-INF/mods.toml") { //Forge,Neoforge + if (isForge(e.entryName)) { //Forge,Neoforge const modid = toml.parse(e.getData().toString('utf-8')).mods[0].modId const body = JSON.parse(await FastGot(`https://dearth.0771010.xyz/api/modid?modid=${modid}`)) if (body.isClient) { @@ -79,7 +79,7 @@ export async function DeEarth(modpath: string, movepath: string) { for (let i = 0; i < zip.length; i++) { const e = zip[i] try { - if (e.entryName == "META-INF/mods.toml") { //Forge,Neoforge + if (isForge(e.entryName)) { //Forge,Neoforge const tr = toml.parse(e.getData().toString('utf-8')) const mcside = tr.dependencies[tr.mods[0].modId].find((mod: { modId: string; }) => mod.modId === "minecraft").side if (mcside == "CLIENT"){ //从Minecraft判断 @@ -159,6 +159,10 @@ const multibar = new MultiBar({ notTTYSchedule: 10*1000, }) +function isForge(name:string):boolean{ + return name.includes("mods.toml")||name.includes("META-INF") +} + function isChinaIpAddress(ipAddress: string) { const chinaRegex = /^((?:(?:1(?:0|1|2[0-7]|[3-9][0-9])|2(?:[0-4][0-9]|5[0-5])|[3-9][0-9]{2})\.){3}(?:(?:1(?:0|1|2[0-7]|[3-9][0-9])|2(?:[0-4][0-9]|5[0-5])|[3-9][0-9]{2})))$/; return chinaRegex.test(ipAddress);