Skip to content

Commit 2c7274e

Browse files
committed
add DOM lib to tsconfig for fetch compatibility
1 parent 591d604 commit 2c7274e

File tree

4 files changed

+22
-97
lines changed

4 files changed

+22
-97
lines changed

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
![logo](https://raw.githubusercontent.com/Luuxis/minecraft-java-core/main/logo.png)
2-
3-
##### v4.0.0 • **minecraft‑java‑core**
1+
##### v4 • **minecraft‑java‑core**
42
[![License: CC‑BY‑NC 4.0](https://img.shields.io/badge/License-CC--BY--NC%204.0-yellow.svg)](https://creativecommons.org/licenses/by-nc/4.0/)
53
![stable version](https://img.shields.io/badge/stable_version-4.0.0-blue)
64

@@ -51,11 +49,8 @@ launcher.on('progress', p => console.log(`[DL] ${p}%`))
5149
await launcher.launch({
5250
root: './minecraft',
5351
authenticator: auth,
54-
version: {
55-
number: '1.20.4',
56-
type: 'release'
57-
},
58-
loader: { type: 'fabric', version: '0.15.9' },
52+
version: '1.20.4',
53+
loader: { type: 'fabric', build: '0.15.9' },
5954
memory: { min: '2G', max: '4G' }
6055
});
6156
```

src/utils/Index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import crypto from 'crypto';
99
import fs from 'fs';
1010
import AdmZip from 'adm-zip';
11-
import path from 'path';
1211

1312
// This interface defines the structure of a Minecraft library rule.
1413
interface LibraryRule {

test/index.js

Lines changed: 16 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,43 @@
1-
const { Microsoft, Launch } = require('../build/Index');
2-
const launch = new Launch();
3-
const fs = require('fs');
1+
const { Launch, Microsoft } = require('minecraft-java-core');
2+
const launcher = new Launch();
43

5-
let client_id = '13f589e1-e2fc-443e-a68a-63b0092b8eeb'
4+
const fs = require('fs');
65
let mc
76

87
(async () => {
98
if (!fs.existsSync('./account.json')) {
10-
mc = await new Microsoft(client_id).getAuth();
9+
mc = await new Microsoft().getAuth();
1110
fs.writeFileSync('./account.json', JSON.stringify(mc, null, 4));
1211
} else {
1312
mc = JSON.parse(fs.readFileSync('./account.json'));
1413
if (!mc.refresh_token) {
15-
mc = await new Microsoft(client_id).getAuth();
14+
mc = await new Microsoft().getAuth();
1615
fs.writeFileSync('./account.json', JSON.stringify(mc, null, 4));
1716
} else {
18-
mc = await new Microsoft(client_id).refresh(mc);
19-
if (mc.error) mc = await new Microsoft(client_id).getAuth();
17+
mc = await new Microsoft().refresh(mc);
18+
if (mc.error) mc = await new Microsoft().getAuth();
2019
fs.writeFileSync('./account.json', JSON.stringify(mc, null, 4));
2120
}
2221
}
2322

24-
let opt = {
23+
await launcher.Launch({
24+
path: './minecraft',
2525
authenticator: mc,
26-
timeout: 1000,
27-
path: './Minecraft',
28-
instance: 'test',
29-
version: '1.1',
30-
detached: false,
26+
version: '1.8.9',
3127
intelEnabledMac: true,
32-
downloadFileMultiple: 5,
33-
3428
loader: {
3529
type: 'forge',
3630
build: 'latest',
3731
enable: true
3832
},
39-
40-
verify: false,
41-
ignored: [
42-
'config',
43-
'essential',
44-
'logs',
45-
'resourcepacks',
46-
'saves',
47-
'screenshots',
48-
'shaderpacks',
49-
'W-OVERFLOW',
50-
'options.txt',
51-
'optionsof.txt'
52-
],
53-
JVM_ARGS: [],
54-
GAME_ARGS: [],
55-
56-
java: {
57-
path: null,
58-
version: null,
59-
type: 'jre',
60-
},
61-
62-
// screen: {
63-
// width: 1500,
64-
// height: 900
65-
// },
66-
6733
memory: {
68-
min: '4G',
69-
max: '6G'
34+
min: '2G',
35+
max: '4G'
7036
}
71-
}
72-
73-
await launch.Launch(opt);
74-
75-
launch.on('extract', extract => {
76-
console.log(extract);
7737
});
7838

79-
launch.on('progress', (progress, size, element) => {
80-
console.log(`Downloading ${element} ${Math.round((progress / size) * 100)}%`);
81-
});
82-
83-
launch.on('check', (progress, size, element) => {
84-
console.log(`Checking ${element} ${Math.round((progress / size) * 100)}%`);
85-
});
86-
87-
launch.on('estimated', (time) => {
88-
let hours = Math.floor(time / 3600);
89-
let minutes = Math.floor((time - hours * 3600) / 60);
90-
let seconds = Math.floor(time - hours * 3600 - minutes * 60);
91-
console.log(`${hours}h ${minutes}m ${seconds}s`);
92-
})
93-
94-
launch.on('speed', (speed) => {
95-
console.log(`${(speed / 1067008).toFixed(2)} Mb/s`)
96-
})
97-
98-
launch.on('patch', patch => {
99-
console.log(patch);
100-
});
101-
102-
launch.on('data', (e) => {
103-
console.log(e);
104-
})
105-
106-
launch.on('close', code => {
107-
console.log(code);
108-
});
109-
110-
launch.on('error', err => {
111-
console.log(err);
112-
});
39+
launcher.on('progress', (progress, size) => console.log(`[DL] ${((progress / size) * 100).toFixed(2)}%`))
40+
.on('patch', pacth => process.stdout.write(pacth))
41+
.on('data', line => process.stdout.write(line))
42+
.on('close', () => console.log('Game exited.'));
11343
})();

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"src/**/*"
44
],
55
"compilerOptions": {
6-
"sourceMap": false,
6+
"sourceMap": true,
77
"target": "ES2020",
88
"module": "CommonJS",
99
"lib": [
10-
"ES2021"
10+
"ES2021",
11+
"DOM"
1112
],
1213
"declaration": true,
1314
"outDir": "build",

0 commit comments

Comments
 (0)