feat:最终
This commit is contained in:
@@ -22,11 +22,10 @@ export class Dex {
|
||||
this.ws = e
|
||||
})
|
||||
this.in = {}
|
||||
console.log(this.ws)
|
||||
}
|
||||
}
|
||||
|
||||
public async Main(buffer: Buffer) {
|
||||
const first = new Date().getTime()
|
||||
const first = Date.now()
|
||||
const info = await this._getinfo(buffer)
|
||||
const plat = what_platform(info)
|
||||
const mpname = this.in.name
|
||||
@@ -46,8 +45,7 @@ export class Dex {
|
||||
})); //改变状态(DeEarth筛选模组完毕)
|
||||
const mlinfo = await platform(plat).getinfo(this.in)
|
||||
await mlsetup(mlinfo.loader,mlinfo.minecraft,mlinfo.loader_version,unpath) //安装服务端
|
||||
const latest = new Date().getTime()
|
||||
console.log(latest - first)
|
||||
const latest = Date.now()
|
||||
this.ws.send(JSON.stringify({
|
||||
status: "finish",
|
||||
result: latest - first
|
||||
|
||||
@@ -40,7 +40,7 @@ export class Fabric{
|
||||
async install(){
|
||||
await execPromise(`java -jar fabric-installer.jar server -dir . -mcversion ${this.minecraft} -loader ${this.loaderVersion}`,{
|
||||
cwd:this.path
|
||||
})
|
||||
}).catch(e=>console.log(e))
|
||||
}
|
||||
|
||||
private async wshell(){
|
||||
|
||||
@@ -30,7 +30,7 @@ export function modloader(ml:string,mcv:string,mlv:string,path:string){
|
||||
|
||||
export async function mlsetup(ml:string,mcv:string,mlv:string,path:string){
|
||||
const minecraft = new Minecraft(ml,mcv,mlv,path);
|
||||
console.log(ml)
|
||||
//console.log(ml)
|
||||
await modloader(ml,mcv,mlv,path).setup()
|
||||
await minecraft.setup()
|
||||
}
|
||||
@@ -88,7 +88,7 @@ export class Minecraft {
|
||||
const mcpath = `${this.path}/server.jar`
|
||||
await fastdownload([`https://bmclapi2.bangbang93.com/version/${this.minecraft}/server`, mcpath])
|
||||
// 依赖解压
|
||||
const zip = await yauzl_promise(await fs.promises.readFile(mcpath))
|
||||
/*const zip = await yauzl_promise(await fs.promises.readFile(mcpath))
|
||||
for await (const entry of zip) {
|
||||
// if (entry.fileName.startsWith("META-INF/libraries/") && entry.fileName.endsWith("/") &&entry.fileName !== "META-INF/libraries/") {
|
||||
// fs.promises.mkdir(`${this.path}/libraries/${entry.fileName.replace("META-INF/libraries/", "")}`,{
|
||||
@@ -105,16 +105,12 @@ export class Minecraft {
|
||||
const out = entry.ReadEntrySync
|
||||
await fsExtra.outputFile(`${this.path}/libraries/${entry.fileName.replace("META-INF/libraries/", "")}`,out)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
// 依赖解压
|
||||
}
|
||||
|
||||
async eula(){
|
||||
const context = `
|
||||
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
|
||||
#Spawn by DeEarthX(QQgroup:559349662) Tianpao:(https://space.bilibili.com/1728953419)
|
||||
eula=true
|
||||
`
|
||||
const context = `#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).\n#Spawn by DeEarthX(QQgroup:559349662) Tianpao:(https://space.bilibili.com/1728953419)\neula=true`
|
||||
await fs.promises.writeFile(`${this.path}/eula.txt`,context)
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import got from "got"
|
||||
import { Utils } from "./utils.js"
|
||||
import pa from "node:path"
|
||||
import WebSocket from "ws"
|
||||
import config from "./config.js"
|
||||
interface IMixins{
|
||||
name: string
|
||||
data: string
|
||||
@@ -43,10 +44,19 @@ export class DeEarth{
|
||||
fs.mkdirSync(this.movepath,{recursive:true})
|
||||
}
|
||||
await this.getFile()
|
||||
const hash = await this.Check_Hashes()
|
||||
const mixins = await this.Check_Mixins()
|
||||
let hash;
|
||||
let mixins;
|
||||
if (config.filter.hashes){ //Hash
|
||||
hash = await this.Check_Hashes()
|
||||
}
|
||||
if (config.filter.mixins){ //Mixins
|
||||
mixins = await this.Check_Mixins()
|
||||
}
|
||||
if(!hash||mixins){
|
||||
return;
|
||||
}
|
||||
const result = [...new Set(hash.concat(mixins))]
|
||||
console.log(result)
|
||||
//console.log(result)
|
||||
result.forEach(async e=>{
|
||||
await fs.promises.rename(`${e}`,`${this.movepath}/${e}`.replace(this.modspath,""))
|
||||
//await fs.promises.rename(`${this.modspath}/${e}`,`${this.movepath}/${e}`)
|
||||
@@ -57,7 +67,7 @@ export class DeEarth{
|
||||
const cmap = new Map<string,string>()
|
||||
const fmap = new Map<string,string>()
|
||||
const hashes:string[] = []
|
||||
const files = this.file.forEach(e=>{
|
||||
this.file.forEach(e=>{
|
||||
hashes.push(e.hash);
|
||||
cmap.set(e.hash,e.filename)
|
||||
})
|
||||
|
||||
7
backend/src/utils/debugger.ts
Normal file
7
backend/src/utils/debugger.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
class Debugger{
|
||||
static log(msg: any){
|
||||
if (process.env.DEBUG){
|
||||
console.log(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,8 @@ export async function fastdownload(data: [string, string]) {
|
||||
return 0;
|
||||
}
|
||||
})();*/
|
||||
console.log(e)
|
||||
|
||||
//console.log(e)
|
||||
await got
|
||||
.get(e[0], {
|
||||
responseType: "buffer",
|
||||
@@ -172,7 +173,7 @@ export async function xfastdownload(data: [string, string][]) {
|
||||
return 0;
|
||||
}
|
||||
})();*/
|
||||
console.log(e)
|
||||
//console.log(e)
|
||||
await got
|
||||
.get(e[0], {
|
||||
responseType: "buffer",
|
||||
|
||||
Reference in New Issue
Block a user