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