chore(HM):禁用bmclapi
This commit is contained in:
@@ -25,7 +25,7 @@ export class Dex {
|
||||
public async Main(buffer: Buffer, dser: boolean) {
|
||||
try {
|
||||
const first = Date.now();
|
||||
const zps = await this._zps(buffer);
|
||||
const zps = await this._zips(buffer);
|
||||
const { contain, info } = await zps._getinfo();
|
||||
const plat = what_platform(contain);
|
||||
logger.debug("Platform detected", plat);
|
||||
@@ -72,7 +72,7 @@ export class Dex {
|
||||
}
|
||||
}
|
||||
|
||||
private async _zps(buffer: Buffer) {
|
||||
private async _zips(buffer: Buffer) {
|
||||
const zip = await yauzl_promise(buffer);
|
||||
const _getinfo = async () => {
|
||||
const importantFiles = ["manifest.json", "modrinth.index.json"];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import got, { Got } from "got";
|
||||
import fs from "node:fs"
|
||||
import { execPromise, fastdownload } from "../utils/utils.js";
|
||||
import config from "../utils/config.js";
|
||||
|
||||
interface ILatestLoader{
|
||||
url:string,
|
||||
@@ -32,7 +33,9 @@ export class Fabric{
|
||||
|
||||
async setup():Promise<void>{
|
||||
await this.installer()
|
||||
await this.libraries()
|
||||
if(config.mirror.bmclapi){
|
||||
await this.libraries()
|
||||
}
|
||||
await this.install()
|
||||
await this.wshell()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import fse from "fs-extra"
|
||||
import { execPromise, fastdownload, version_compare } from "../utils/utils.js";
|
||||
import { Azip } from "../utils/ziplib.js";
|
||||
import { execSync } from "node:child_process";
|
||||
import config from "../utils/config.js";
|
||||
|
||||
interface Iforge{
|
||||
data:{
|
||||
@@ -34,14 +35,26 @@ export class Forge {
|
||||
this.loaderVersion = loaderVersion;
|
||||
this.path = path
|
||||
this.got = got.extend({
|
||||
prefixUrl: "https://bmclapi2.bangbang93.com",
|
||||
headers: { "User-Agent": "DeEarthX" },
|
||||
hooks: {
|
||||
init: [
|
||||
(options) => {
|
||||
if(config.mirror.bmclapi){
|
||||
options.prefixUrl = "https://bmclapi2.bangbang93.com";
|
||||
}else{
|
||||
options.prefixUrl = "http://maven.minecraftforge.net/";
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async setup(){
|
||||
await this.installer()
|
||||
await this.library()
|
||||
if(config.mirror.bmclapi){
|
||||
await this.library()
|
||||
}
|
||||
await this.install()
|
||||
if (version_compare(this.minecraft,"1.18") === -1){
|
||||
await this.wshell()
|
||||
@@ -84,7 +97,11 @@ export class Forge {
|
||||
}
|
||||
|
||||
async installer(){
|
||||
const res = (await this.got.get(`forge/download?mcversion=${this.minecraft}&version=${this.loaderVersion}&category=installer&format=jar`)).rawBody;
|
||||
let url = `forge/download?mcversion=${this.minecraft}&version=${this.loaderVersion}&category=installer&format=jar`
|
||||
if(!config.mirror?.bmclapi){
|
||||
url = `net/minecraftforge/forge/${this.minecraft}-${this.loaderVersion}/forge-${this.minecraft}-${this.loaderVersion}-installer.jar`
|
||||
}
|
||||
const res = (await this.got.get(url)).rawBody;
|
||||
await fse.outputFile(`${this.path}/forge-${this.minecraft}-${this.loaderVersion}-installer.jar`,res);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { fastdownload, version_compare } from "../utils/utils.js";
|
||||
import { pipeline } from "node:stream/promises";
|
||||
import got from "got";
|
||||
import { Azip } from "../utils/ziplib.js";
|
||||
import config from "../utils/config.js";
|
||||
|
||||
interface ILInfo {
|
||||
libraries: {
|
||||
@@ -27,6 +28,10 @@ export class Minecraft {
|
||||
}
|
||||
|
||||
async setup() {
|
||||
await this.eula() //生成Eula.txt
|
||||
if(!config.mirror.bmclapi){
|
||||
return;
|
||||
}
|
||||
switch (this.loader) {
|
||||
case "forge":
|
||||
await this.forge_setup();
|
||||
@@ -41,7 +46,6 @@ export class Minecraft {
|
||||
await this.fabric_setup();
|
||||
break;
|
||||
}
|
||||
await this.eula() //生成Eula.txt
|
||||
}
|
||||
|
||||
async forge_setup() {
|
||||
|
||||
@@ -1,19 +1,42 @@
|
||||
import fse from "fs-extra"
|
||||
import { Forge } from "./forge.js";
|
||||
import config from "../utils/config.js";
|
||||
import { Got,got } from "got";
|
||||
|
||||
export class NeoForge extends Forge{
|
||||
got: Got;
|
||||
constructor(minecraft:string,loaderVersion:string,path:string){
|
||||
super(minecraft,loaderVersion,path); //子承父业
|
||||
this.got = got.extend({
|
||||
headers: { "User-Agent": "DeEarthX" },
|
||||
hooks: {
|
||||
init: [
|
||||
(options) => {
|
||||
if(config.mirror?.bmclapi){
|
||||
options.prefixUrl = "https://bmclapi2.bangbang93.com/"
|
||||
}else{
|
||||
options.prefixUrl = "https://maven.neoforged.net/releases/";
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async setup(){
|
||||
await this.installer();
|
||||
await this.library();
|
||||
if(config.mirror.bmclapi){
|
||||
await this.library();
|
||||
}
|
||||
await this.install();
|
||||
}
|
||||
|
||||
async installer(){
|
||||
const res = (await this.got.get(`neoforge/version/${this.loaderVersion}/download/installer.jar`)).rawBody;
|
||||
let url = `neoforge/version/${this.loaderVersion}/download/installer.jar`;
|
||||
if(!config.mirror?.bmclapi){
|
||||
url = `net/neoforged/neoforge/${this.loaderVersion}/neoforge-${this.loaderVersion}-installer.jar`
|
||||
}
|
||||
const res = (await this.got.get(url)).rawBody;
|
||||
await fse.outputFile(`${this.path}/forge-${this.minecraft}-${this.loaderVersion}-installer.jar`,res);
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,8 @@ const settings: SettingCategory[] = [
|
||||
},
|
||||
{
|
||||
key: 'dexpub',
|
||||
name: 'DeP过滤',
|
||||
description: '过滤 DeP 平台中记录的客户端文件',
|
||||
name: 'DePIS过滤',
|
||||
description: '过滤 DeEarth Public Info Services 平台中记录的客户端文件',
|
||||
path: 'filter.dexpub',
|
||||
defaultValue: false
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user