fix:DeEarth无法识别NeoForge
This commit is contained in:
@@ -41,7 +41,7 @@ export async function DeEarth(modpath: string, movepath: string) {
|
|||||||
try { //Modrinth
|
try { //Modrinth
|
||||||
for (let i = 0; i < zip.length; i++) {
|
for (let i = 0; i < zip.length; i++) {
|
||||||
const e = zip[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 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 = 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}`))
|
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
|
try{//DeEarthPublic
|
||||||
for (let i = 0; i < zip.length; i++) {
|
for (let i = 0; i < zip.length; i++) {
|
||||||
const e = zip[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 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}`))
|
const body = JSON.parse(await FastGot(`https://dearth.0771010.xyz/api/modid?modid=${modid}`))
|
||||||
if (body.isClient) {
|
if (body.isClient) {
|
||||||
@@ -79,7 +79,7 @@ export async function DeEarth(modpath: string, movepath: string) {
|
|||||||
for (let i = 0; i < zip.length; i++) {
|
for (let i = 0; i < zip.length; i++) {
|
||||||
const e = zip[i]
|
const e = zip[i]
|
||||||
try {
|
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 tr = toml.parse(e.getData().toString('utf-8'))
|
||||||
const mcside = tr.dependencies[tr.mods[0].modId].find((mod: { modId: string; }) => mod.modId === "minecraft").side
|
const mcside = tr.dependencies[tr.mods[0].modId].find((mod: { modId: string; }) => mod.modId === "minecraft").side
|
||||||
if (mcside == "CLIENT"){ //从Minecraft判断
|
if (mcside == "CLIENT"){ //从Minecraft判断
|
||||||
@@ -159,6 +159,10 @@ const multibar = new MultiBar({
|
|||||||
notTTYSchedule: 10*1000,
|
notTTYSchedule: 10*1000,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function isForge(name:string):boolean{
|
||||||
|
return name.includes("mods.toml")||name.includes("META-INF")
|
||||||
|
}
|
||||||
|
|
||||||
function isChinaIpAddress(ipAddress: string) {
|
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})))$/;
|
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);
|
return chinaRegex.test(ipAddress);
|
||||||
|
|||||||
Reference in New Issue
Block a user