Compare commits
51 Commits
bf65923c00
...
renovate/n
Author | SHA1 | Date | |
---|---|---|---|
398cfa9c32 | |||
13596e5a2b | |||
ff230e5367 | |||
5e0264b9d4 | |||
8c57aa5bb9 | |||
dbb0395865 | |||
86c6f613e6 | |||
38fe9ba42a | |||
869e8343d0 | |||
c3ed0aa017 | |||
009b5acb85 | |||
a6d21ce762 | |||
9edb9401a4 | |||
0ed1ce3975 | |||
0f051bb8ca | |||
e782221718 | |||
ada236d20e | |||
1be2f328da | |||
b5d96d1dd4 | |||
bbf5a6e50a | |||
d2a3434205 | |||
c909b11b0c | |||
68c9ac8a05 | |||
74426ff59d | |||
2f17c4d218 | |||
321db2fb3d | |||
c625a70a59 | |||
436c9be3e5 | |||
db98cf20a1 | |||
9eaf6125b7 | |||
2f666a9cfa | |||
8c2c03eba5 | |||
634fda168e | |||
757da0c8e9 | |||
6f56a00083 | |||
dc93325992 | |||
efdf121a42 | |||
0a11d1ab86 | |||
f68b340f6f | |||
37af4ebbbd | |||
7693e7055b | |||
a815112fb9 | |||
bdc56e454a | |||
cbb534adf4 | |||
3e020337e3 | |||
e4bbc0338f | |||
5a9caf9614 | |||
69b7d28111 | |||
eb9ab2cd5b | |||
fb8ab8d7aa | |||
e8993e0de6 |
33
README.md
33
README.md
@ -1,34 +1,3 @@
|
||||
# Minecraft Utilities - Javascript Library
|
||||
|
||||
The JavaScript library for the Minecraft Utilities API.
|
||||
|
||||
## Usage
|
||||
|
||||
Install the package using npm:
|
||||
|
||||
```bash
|
||||
npm install mcutils-library
|
||||
```
|
||||
|
||||
Get player:
|
||||
|
||||
```javascript
|
||||
import { getPlayer } from "mcutils-library";
|
||||
|
||||
const cachedPlayer = await getPlayer(playerId);
|
||||
const { player } = cachedPlayer;
|
||||
|
||||
console.log(player);
|
||||
```
|
||||
|
||||
Get Server:
|
||||
|
||||
```javascript
|
||||
import { getServer } from "mcutils-library";
|
||||
import JavaMinecraftServer from "mcutils-library/dist/types/server/javaServer";
|
||||
|
||||
const cachedServer = await getServer(ServerPlatform.Java, "hypixel.net");
|
||||
const { server } = cachedServer;
|
||||
|
||||
console.log(server);
|
||||
```
|
||||
See [The Website](https://mcutils.xyz) or [Minecraft Utilities Documentation](https://mcutils.xyz/docs) for more information.
|
@ -1,4 +1,4 @@
|
||||
import { Config } from "jest";
|
||||
import {Config} from "jest";
|
||||
|
||||
// Sync object
|
||||
const config: Config = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mcutils-library",
|
||||
"version": "1.1.4",
|
||||
"version": "1.3.4",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
@ -14,7 +14,6 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"axios": "^1.6.8",
|
||||
"jest": "^29.7.0",
|
||||
"ts-jest": "^29.1.2",
|
||||
"ts-node": "^10.9.2",
|
||||
|
225
pnpm-lock.yaml
generated
225
pnpm-lock.yaml
generated
@ -5,21 +5,18 @@ settings:
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
axios:
|
||||
specifier: ^1.6.8
|
||||
version: 1.6.8
|
||||
jest:
|
||||
specifier: ^29.7.0
|
||||
version: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2)
|
||||
version: 29.7.0(@types/node@20.14.15)(ts-node@10.9.2)
|
||||
ts-jest:
|
||||
specifier: ^29.1.2
|
||||
version: 29.1.2(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.4.5)
|
||||
version: 29.2.4(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.5.4)
|
||||
ts-node:
|
||||
specifier: ^10.9.2
|
||||
version: 10.9.2(@types/node@20.12.7)(typescript@5.4.5)
|
||||
version: 10.9.2(@types/node@20.14.15)(typescript@5.5.4)
|
||||
typescript:
|
||||
specifier: ^5.4.5
|
||||
version: 5.4.5
|
||||
version: 5.5.4
|
||||
|
||||
devDependencies:
|
||||
'@types/jest':
|
||||
@ -27,7 +24,7 @@ devDependencies:
|
||||
version: 29.5.12
|
||||
'@types/node':
|
||||
specifier: ^20.12.7
|
||||
version: 20.12.7
|
||||
version: 20.14.15
|
||||
|
||||
packages:
|
||||
|
||||
@ -394,7 +391,7 @@ packages:
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
chalk: 4.1.2
|
||||
jest-message-util: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
@ -415,14 +412,14 @@ packages:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
ansi-escapes: 4.3.2
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.9.0
|
||||
exit: 0.1.2
|
||||
graceful-fs: 4.2.11
|
||||
jest-changed-files: 29.7.0
|
||||
jest-config: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2)
|
||||
jest-config: 29.7.0(@types/node@20.14.15)(ts-node@10.9.2)
|
||||
jest-haste-map: 29.7.0
|
||||
jest-message-util: 29.7.0
|
||||
jest-regex-util: 29.6.3
|
||||
@ -450,7 +447,7 @@ packages:
|
||||
dependencies:
|
||||
'@jest/fake-timers': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
jest-mock: 29.7.0
|
||||
dev: false
|
||||
|
||||
@ -476,7 +473,7 @@ packages:
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@sinonjs/fake-timers': 10.3.0
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
jest-message-util: 29.7.0
|
||||
jest-mock: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
@ -509,7 +506,7 @@ packages:
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@jridgewell/trace-mapping': 0.3.25
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
chalk: 4.1.2
|
||||
collect-v8-coverage: 1.0.2
|
||||
exit: 0.1.2
|
||||
@ -596,7 +593,7 @@ packages:
|
||||
'@jest/schemas': 29.6.3
|
||||
'@types/istanbul-lib-coverage': 2.0.6
|
||||
'@types/istanbul-reports': 3.0.4
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
'@types/yargs': 17.0.32
|
||||
chalk: 4.1.2
|
||||
|
||||
@ -700,7 +697,7 @@ packages:
|
||||
/@types/graceful-fs@4.1.9:
|
||||
resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==}
|
||||
dependencies:
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
dev: false
|
||||
|
||||
/@types/istanbul-lib-coverage@2.0.6:
|
||||
@ -723,8 +720,8 @@ packages:
|
||||
pretty-format: 29.7.0
|
||||
dev: true
|
||||
|
||||
/@types/node@20.12.7:
|
||||
resolution: {integrity: sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==}
|
||||
/@types/node@20.14.15:
|
||||
resolution: {integrity: sha512-Fz1xDMCF/B00/tYSVMlmK7hVeLh7jE5f3B7X1/hmV0MJBwE27KlS7EvD/Yp+z1lm8mVhwV5w+n8jOZG8AfTlKw==}
|
||||
dependencies:
|
||||
undici-types: 5.26.5
|
||||
|
||||
@ -796,18 +793,8 @@ packages:
|
||||
sprintf-js: 1.0.3
|
||||
dev: false
|
||||
|
||||
/asynckit@0.4.0:
|
||||
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
||||
dev: false
|
||||
|
||||
/axios@1.6.8:
|
||||
resolution: {integrity: sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==}
|
||||
dependencies:
|
||||
follow-redirects: 1.15.6
|
||||
form-data: 4.0.0
|
||||
proxy-from-env: 1.1.0
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
/async@3.2.5:
|
||||
resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==}
|
||||
dev: false
|
||||
|
||||
/babel-jest@29.7.0(@babel/core@7.24.4):
|
||||
@ -893,6 +880,12 @@ packages:
|
||||
concat-map: 0.0.1
|
||||
dev: false
|
||||
|
||||
/brace-expansion@2.0.1:
|
||||
resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==}
|
||||
dependencies:
|
||||
balanced-match: 1.0.2
|
||||
dev: false
|
||||
|
||||
/braces@3.0.2:
|
||||
resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==}
|
||||
engines: {node: '>=8'}
|
||||
@ -1009,13 +1002,6 @@ packages:
|
||||
/color-name@1.1.4:
|
||||
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||
|
||||
/combined-stream@1.0.8:
|
||||
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
dependencies:
|
||||
delayed-stream: 1.0.0
|
||||
dev: false
|
||||
|
||||
/concat-map@0.0.1:
|
||||
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
||||
dev: false
|
||||
@ -1024,7 +1010,7 @@ packages:
|
||||
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
|
||||
dev: false
|
||||
|
||||
/create-jest@29.7.0(@types/node@20.12.7)(ts-node@10.9.2):
|
||||
/create-jest@29.7.0(@types/node@20.14.15)(ts-node@10.9.2):
|
||||
resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
@ -1033,7 +1019,7 @@ packages:
|
||||
chalk: 4.1.2
|
||||
exit: 0.1.2
|
||||
graceful-fs: 4.2.11
|
||||
jest-config: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2)
|
||||
jest-config: 29.7.0(@types/node@20.14.15)(ts-node@10.9.2)
|
||||
jest-util: 29.7.0
|
||||
prompts: 2.4.2
|
||||
transitivePeerDependencies:
|
||||
@ -1082,11 +1068,6 @@ packages:
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: false
|
||||
|
||||
/delayed-stream@1.0.0:
|
||||
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
dev: false
|
||||
|
||||
/detect-newline@3.1.0:
|
||||
resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==}
|
||||
engines: {node: '>=8'}
|
||||
@ -1101,6 +1082,14 @@ packages:
|
||||
engines: {node: '>=0.3.1'}
|
||||
dev: false
|
||||
|
||||
/ejs@3.1.10:
|
||||
resolution: {integrity: sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
jake: 10.9.2
|
||||
dev: false
|
||||
|
||||
/electron-to-chromium@1.4.736:
|
||||
resolution: {integrity: sha512-Rer6wc3ynLelKNM4lOCg7/zPQj8tPOCB2hzD32PX9wd3hgRRi9MxEbmkFCokzcEhRVMiOVLjnL9ig9cefJ+6+Q==}
|
||||
dev: false
|
||||
@ -1179,6 +1168,12 @@ packages:
|
||||
bser: 2.1.1
|
||||
dev: false
|
||||
|
||||
/filelist@1.0.4:
|
||||
resolution: {integrity: sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==}
|
||||
dependencies:
|
||||
minimatch: 5.1.6
|
||||
dev: false
|
||||
|
||||
/fill-range@7.0.1:
|
||||
resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==}
|
||||
engines: {node: '>=8'}
|
||||
@ -1193,25 +1188,6 @@ packages:
|
||||
path-exists: 4.0.0
|
||||
dev: false
|
||||
|
||||
/follow-redirects@1.15.6:
|
||||
resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==}
|
||||
engines: {node: '>=4.0'}
|
||||
peerDependencies:
|
||||
debug: '*'
|
||||
peerDependenciesMeta:
|
||||
debug:
|
||||
optional: true
|
||||
dev: false
|
||||
|
||||
/form-data@4.0.0:
|
||||
resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==}
|
||||
engines: {node: '>= 6'}
|
||||
dependencies:
|
||||
asynckit: 0.4.0
|
||||
combined-stream: 1.0.8
|
||||
mime-types: 2.1.35
|
||||
dev: false
|
||||
|
||||
/fs.realpath@1.0.0:
|
||||
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
|
||||
dev: false
|
||||
@ -1375,7 +1351,7 @@ packages:
|
||||
'@babel/parser': 7.24.4
|
||||
'@istanbuljs/schema': 0.1.3
|
||||
istanbul-lib-coverage: 3.2.2
|
||||
semver: 7.6.0
|
||||
semver: 7.6.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
@ -1408,6 +1384,17 @@ packages:
|
||||
istanbul-lib-report: 3.0.1
|
||||
dev: false
|
||||
|
||||
/jake@10.9.2:
|
||||
resolution: {integrity: sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
async: 3.2.5
|
||||
chalk: 4.1.2
|
||||
filelist: 1.0.4
|
||||
minimatch: 3.1.2
|
||||
dev: false
|
||||
|
||||
/jest-changed-files@29.7.0:
|
||||
resolution: {integrity: sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
@ -1425,7 +1412,7 @@ packages:
|
||||
'@jest/expect': 29.7.0
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
chalk: 4.1.2
|
||||
co: 4.6.0
|
||||
dedent: 1.5.3
|
||||
@ -1446,7 +1433,7 @@ packages:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/jest-cli@29.7.0(@types/node@20.12.7)(ts-node@10.9.2):
|
||||
/jest-cli@29.7.0(@types/node@20.14.15)(ts-node@10.9.2):
|
||||
resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
@ -1460,10 +1447,10 @@ packages:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
chalk: 4.1.2
|
||||
create-jest: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2)
|
||||
create-jest: 29.7.0(@types/node@20.14.15)(ts-node@10.9.2)
|
||||
exit: 0.1.2
|
||||
import-local: 3.1.0
|
||||
jest-config: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2)
|
||||
jest-config: 29.7.0(@types/node@20.14.15)(ts-node@10.9.2)
|
||||
jest-util: 29.7.0
|
||||
jest-validate: 29.7.0
|
||||
yargs: 17.7.2
|
||||
@ -1474,7 +1461,7 @@ packages:
|
||||
- ts-node
|
||||
dev: false
|
||||
|
||||
/jest-config@29.7.0(@types/node@20.12.7)(ts-node@10.9.2):
|
||||
/jest-config@29.7.0(@types/node@20.14.15)(ts-node@10.9.2):
|
||||
resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
peerDependencies:
|
||||
@ -1489,7 +1476,7 @@ packages:
|
||||
'@babel/core': 7.24.4
|
||||
'@jest/test-sequencer': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
babel-jest: 29.7.0(@babel/core@7.24.4)
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.9.0
|
||||
@ -1509,7 +1496,7 @@ packages:
|
||||
pretty-format: 29.7.0
|
||||
slash: 3.0.0
|
||||
strip-json-comments: 3.1.1
|
||||
ts-node: 10.9.2(@types/node@20.12.7)(typescript@5.4.5)
|
||||
ts-node: 10.9.2(@types/node@20.14.15)(typescript@5.5.4)
|
||||
transitivePeerDependencies:
|
||||
- babel-plugin-macros
|
||||
- supports-color
|
||||
@ -1549,7 +1536,7 @@ packages:
|
||||
'@jest/environment': 29.7.0
|
||||
'@jest/fake-timers': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
jest-mock: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
dev: false
|
||||
@ -1564,7 +1551,7 @@ packages:
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/graceful-fs': 4.1.9
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
anymatch: 3.1.3
|
||||
fb-watchman: 2.0.2
|
||||
graceful-fs: 4.2.11
|
||||
@ -1613,7 +1600,7 @@ packages:
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
jest-util: 29.7.0
|
||||
dev: false
|
||||
|
||||
@ -1668,7 +1655,7 @@ packages:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
chalk: 4.1.2
|
||||
emittery: 0.13.1
|
||||
graceful-fs: 4.2.11
|
||||
@ -1699,7 +1686,7 @@ packages:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
chalk: 4.1.2
|
||||
cjs-module-lexer: 1.2.3
|
||||
collect-v8-coverage: 1.0.2
|
||||
@ -1741,7 +1728,7 @@ packages:
|
||||
jest-util: 29.7.0
|
||||
natural-compare: 1.4.0
|
||||
pretty-format: 29.7.0
|
||||
semver: 7.6.0
|
||||
semver: 7.6.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
@ -1751,7 +1738,7 @@ packages:
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.9.0
|
||||
graceful-fs: 4.2.11
|
||||
@ -1775,7 +1762,7 @@ packages:
|
||||
dependencies:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
ansi-escapes: 4.3.2
|
||||
chalk: 4.1.2
|
||||
emittery: 0.13.1
|
||||
@ -1787,13 +1774,13 @@ packages:
|
||||
resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
jest-util: 29.7.0
|
||||
merge-stream: 2.0.0
|
||||
supports-color: 8.1.1
|
||||
dev: false
|
||||
|
||||
/jest@29.7.0(@types/node@20.12.7)(ts-node@10.9.2):
|
||||
/jest@29.7.0(@types/node@20.14.15)(ts-node@10.9.2):
|
||||
resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
@ -1806,7 +1793,7 @@ packages:
|
||||
'@jest/core': 29.7.0(ts-node@10.9.2)
|
||||
'@jest/types': 29.6.3
|
||||
import-local: 3.1.0
|
||||
jest-cli: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2)
|
||||
jest-cli: 29.7.0(@types/node@20.14.15)(ts-node@10.9.2)
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- babel-plugin-macros
|
||||
@ -1872,18 +1859,11 @@ packages:
|
||||
yallist: 3.1.1
|
||||
dev: false
|
||||
|
||||
/lru-cache@6.0.0:
|
||||
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
|
||||
engines: {node: '>=10'}
|
||||
dependencies:
|
||||
yallist: 4.0.0
|
||||
dev: false
|
||||
|
||||
/make-dir@4.0.0:
|
||||
resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==}
|
||||
engines: {node: '>=10'}
|
||||
dependencies:
|
||||
semver: 7.6.0
|
||||
semver: 7.6.3
|
||||
dev: false
|
||||
|
||||
/make-error@1.3.6:
|
||||
@ -1907,18 +1887,6 @@ packages:
|
||||
braces: 3.0.2
|
||||
picomatch: 2.3.1
|
||||
|
||||
/mime-db@1.52.0:
|
||||
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
dev: false
|
||||
|
||||
/mime-types@2.1.35:
|
||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
dependencies:
|
||||
mime-db: 1.52.0
|
||||
dev: false
|
||||
|
||||
/mimic-fn@2.1.0:
|
||||
resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
|
||||
engines: {node: '>=6'}
|
||||
@ -1930,6 +1898,13 @@ packages:
|
||||
brace-expansion: 1.1.11
|
||||
dev: false
|
||||
|
||||
/minimatch@5.1.6:
|
||||
resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==}
|
||||
engines: {node: '>=10'}
|
||||
dependencies:
|
||||
brace-expansion: 2.0.1
|
||||
dev: false
|
||||
|
||||
/ms@2.1.2:
|
||||
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
|
||||
dev: false
|
||||
@ -2061,10 +2036,6 @@ packages:
|
||||
sisteransi: 1.0.5
|
||||
dev: false
|
||||
|
||||
/proxy-from-env@1.1.0:
|
||||
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
|
||||
dev: false
|
||||
|
||||
/pure-rand@6.1.0:
|
||||
resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==}
|
||||
dev: false
|
||||
@ -2108,12 +2079,16 @@ packages:
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/semver@7.6.0:
|
||||
resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==}
|
||||
/semver@7.6.2:
|
||||
resolution: {integrity: sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/semver@7.6.3:
|
||||
resolution: {integrity: sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
lru-cache: 6.0.0
|
||||
dev: false
|
||||
|
||||
/shebang-command@2.0.0:
|
||||
@ -2249,12 +2224,13 @@ packages:
|
||||
dependencies:
|
||||
is-number: 7.0.0
|
||||
|
||||
/ts-jest@29.1.2(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.4.5):
|
||||
resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==}
|
||||
engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0}
|
||||
/ts-jest@29.2.4(@babel/core@7.24.4)(jest@29.7.0)(typescript@5.5.4):
|
||||
resolution: {integrity: sha512-3d6tgDyhCI29HlpwIq87sNuI+3Q6GLTTCeYRHCs7vDz+/3GCMwEtV9jezLyl4ZtnBgx00I7hm8PCP8cTksMGrw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@babel/core': '>=7.0.0-beta.0 <8'
|
||||
'@jest/transform': ^29.0.0
|
||||
'@jest/types': ^29.0.0
|
||||
babel-jest: ^29.0.0
|
||||
esbuild: '*'
|
||||
@ -2263,6 +2239,8 @@ packages:
|
||||
peerDependenciesMeta:
|
||||
'@babel/core':
|
||||
optional: true
|
||||
'@jest/transform':
|
||||
optional: true
|
||||
'@jest/types':
|
||||
optional: true
|
||||
babel-jest:
|
||||
@ -2272,18 +2250,19 @@ packages:
|
||||
dependencies:
|
||||
'@babel/core': 7.24.4
|
||||
bs-logger: 0.2.6
|
||||
ejs: 3.1.10
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
jest: 29.7.0(@types/node@20.12.7)(ts-node@10.9.2)
|
||||
jest: 29.7.0(@types/node@20.14.15)(ts-node@10.9.2)
|
||||
jest-util: 29.7.0
|
||||
json5: 2.2.3
|
||||
lodash.memoize: 4.1.2
|
||||
make-error: 1.3.6
|
||||
semver: 7.6.0
|
||||
typescript: 5.4.5
|
||||
semver: 7.6.3
|
||||
typescript: 5.5.4
|
||||
yargs-parser: 21.1.1
|
||||
dev: false
|
||||
|
||||
/ts-node@10.9.2(@types/node@20.12.7)(typescript@5.4.5):
|
||||
/ts-node@10.9.2(@types/node@20.14.15)(typescript@5.5.4):
|
||||
resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
@ -2302,14 +2281,14 @@ packages:
|
||||
'@tsconfig/node12': 1.0.11
|
||||
'@tsconfig/node14': 1.0.3
|
||||
'@tsconfig/node16': 1.0.4
|
||||
'@types/node': 20.12.7
|
||||
'@types/node': 20.14.15
|
||||
acorn: 8.11.3
|
||||
acorn-walk: 8.3.2
|
||||
arg: 4.1.3
|
||||
create-require: 1.1.1
|
||||
diff: 4.0.2
|
||||
make-error: 1.3.6
|
||||
typescript: 5.4.5
|
||||
typescript: 5.5.4
|
||||
v8-compile-cache-lib: 3.0.1
|
||||
yn: 3.1.1
|
||||
dev: false
|
||||
@ -2324,8 +2303,8 @@ packages:
|
||||
engines: {node: '>=10'}
|
||||
dev: false
|
||||
|
||||
/typescript@5.4.5:
|
||||
resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==}
|
||||
/typescript@5.5.4:
|
||||
resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
dev: false
|
||||
@ -2401,10 +2380,6 @@ packages:
|
||||
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
|
||||
dev: false
|
||||
|
||||
/yallist@4.0.0:
|
||||
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
|
||||
dev: false
|
||||
|
||||
/yargs-parser@21.1.1:
|
||||
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
|
||||
engines: {node: '>=12'}
|
||||
|
6
renovate.json
Normal file
6
renovate.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
]
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import axios from "axios";
|
||||
import { Error } from "../types/error";
|
||||
import {McUtilsAPIError} from "../types/error";
|
||||
|
||||
export default class WebRequest {
|
||||
/**
|
||||
@ -10,29 +9,40 @@ export default class WebRequest {
|
||||
*/
|
||||
public static get<T>(url: string): Promise<T> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const response = await axios.get(url, {
|
||||
validateStatus: () => true, // Don't throw errors
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
"User-Agent": "McUtils-JS-Library/1.0",
|
||||
},
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
// Resolve with a buffer if the content type is an image
|
||||
if (response.headers.get("content-type")?.includes("image/")) {
|
||||
const arrayBuffer = await response.arrayBuffer();
|
||||
resolve(Buffer.from(arrayBuffer) as unknown as T);
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// Reject if the status code is not 200
|
||||
if (response.status !== 200) {
|
||||
reject(data as Error);
|
||||
if (!response.ok) {
|
||||
reject(data as McUtilsAPIError);
|
||||
return;
|
||||
}
|
||||
|
||||
// Resolve with a buffer if the content type is an image
|
||||
if (response.headers["content-type"].includes("image/")) {
|
||||
resolve(Buffer.from(data, "utf-8") as unknown as T);
|
||||
if (response.headers.get("content-type")?.includes("image/")) {
|
||||
const arrayBuffer = await response.arrayBuffer();
|
||||
resolve(Buffer.from(arrayBuffer) as unknown as T);
|
||||
return;
|
||||
}
|
||||
|
||||
// Resolve with the data
|
||||
resolve(data as T);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
17
src/index.ts
17
src/index.ts
@ -1,5 +1,22 @@
|
||||
/**
|
||||
* The base URL for the API.
|
||||
*/
|
||||
export const API_ENDPOINT = "https://api.mcutils.xyz";
|
||||
|
||||
// Methods
|
||||
export * from "./lib/mojang";
|
||||
export * from "./lib/player";
|
||||
export * from "./lib/server";
|
||||
|
||||
// Types
|
||||
export * from "./types/cache";
|
||||
export * from "./types/error";
|
||||
export * from "./types/mojang/endpoint-status";
|
||||
export * from "./types/player/player";
|
||||
export * from "./types/player/usernameToUuid";
|
||||
export * from "./types/server/blocked-status";
|
||||
export * from "./types/server/platform";
|
||||
export * from "./types/server/platform/bedrock-server";
|
||||
export * from "./types/server/platform/java-server";
|
||||
export * from "./types/server/server";
|
||||
export * from "./types/status";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { API_ENDPOINT } from "..";
|
||||
import {EndpointStatuses} from "types/mojang/endpoint-status";
|
||||
import {API_ENDPOINT} from "..";
|
||||
import WebRequest from "../common/WebRequest";
|
||||
import { CachedEndpointStatus } from "../types/cache/cachedEndpointStatus";
|
||||
|
||||
const endpointStatusEndpoint = API_ENDPOINT + "/mojang/status";
|
||||
|
||||
@ -9,6 +9,6 @@ const endpointStatusEndpoint = API_ENDPOINT + "/mojang/status";
|
||||
*
|
||||
* @returns the Mojang API status
|
||||
*/
|
||||
export function getMojangEndpointStatus(): Promise<CachedEndpointStatus> {
|
||||
return WebRequest.get(endpointStatusEndpoint);
|
||||
export async function getMojangEndpointStatus(): Promise<EndpointStatuses> {
|
||||
return WebRequest.get<EndpointStatuses>(endpointStatusEndpoint);
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
import { API_ENDPOINT } from "..";
|
||||
import {API_ENDPOINT, CachedPlayer, CachedUsernameToUuid} from "..";
|
||||
import WebRequest from "../common/WebRequest";
|
||||
import { CachedPlayer } from "../types/cache/cachedPlayer";
|
||||
import { CachedUsernameToUuid } from "../types/cache/cachedUsernameToUuid";
|
||||
|
||||
const playerEndpoint = API_ENDPOINT + "/player/{id}";
|
||||
const playerUsernameToUuidEndpoint = API_ENDPOINT + "/player/uuid/{id}";
|
||||
@ -13,7 +11,7 @@ const playerSkinPartEndpoint = API_ENDPOINT + "/player/{part}/{id}";
|
||||
* @param id the id of the player
|
||||
* @returns the player information, or null if the player does not exist
|
||||
*/
|
||||
export function getPlayer(id: string): Promise<CachedPlayer> {
|
||||
export async function getPlayer(id: string): Promise<CachedPlayer> {
|
||||
return WebRequest.get<CachedPlayer>(playerEndpoint.replace("{id}", id));
|
||||
}
|
||||
|
||||
@ -23,7 +21,7 @@ export function getPlayer(id: string): Promise<CachedPlayer> {
|
||||
* @param id the id of the player
|
||||
* @returns the player's UUID, or null if the player does not exist
|
||||
*/
|
||||
export function getPlayerUuid(id: string): Promise<CachedUsernameToUuid> {
|
||||
export async function getPlayerUuid(id: string): Promise<CachedUsernameToUuid> {
|
||||
return WebRequest.get<CachedUsernameToUuid>(playerUsernameToUuidEndpoint.replace("{id}", id));
|
||||
}
|
||||
|
||||
@ -34,6 +32,6 @@ export function getPlayerUuid(id: string): Promise<CachedUsernameToUuid> {
|
||||
* @param id the id of the player
|
||||
* @returns the player's skin part, or null if the player does not exist
|
||||
*/
|
||||
export function getPlayerSkinPart(part: string, id: string): Promise<Buffer> {
|
||||
export async function getPlayerSkinPart(part: string, id: string): Promise<Buffer> {
|
||||
return WebRequest.get<Buffer>(playerSkinPartEndpoint.replace("{part}", part).replace("{id}", id));
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { API_ENDPOINT } from "..";
|
||||
import {API_ENDPOINT, CachedBedrockMinecraftServer, CachedJavaMinecraftServer} from "..";
|
||||
import WebRequest from "../common/WebRequest";
|
||||
import { CachedMinecraftServer } from "../types/cache/cachedMinecraftServer";
|
||||
import { BlockedStatus } from "../types/server/blockedStatus";
|
||||
import { ServerPlatform } from "../types/server/platform";
|
||||
import {BlockedStatus} from "../types/server/blocked-status";
|
||||
import {ServerPlatform} from "../types/server/platform";
|
||||
|
||||
const serverEndpoint = API_ENDPOINT + "/server/{platform}/{hostname}";
|
||||
const serverIconEndpoint = API_ENDPOINT + "/server/icon/{hostname}";
|
||||
const serverPreviewEndpoint = API_ENDPOINT + "/server/{platform}/preview/{hostname}";
|
||||
const blockedServerEndpoint = API_ENDPOINT + "/server/blocked/{hostname}";
|
||||
|
||||
/**
|
||||
@ -16,9 +16,13 @@ const blockedServerEndpoint = API_ENDPOINT + "/server/blocked/{hostname}";
|
||||
* @param port the port of the server
|
||||
* @returns the server information, or null if the server does not exist
|
||||
*/
|
||||
export function getServer(platform: ServerPlatform, hostname: string, port?: 25565): Promise<CachedMinecraftServer> {
|
||||
export async function getServer(
|
||||
platform: ServerPlatform,
|
||||
hostname: string,
|
||||
port?: 25565
|
||||
): Promise<CachedJavaMinecraftServer | CachedBedrockMinecraftServer> {
|
||||
const ip = port ? `${hostname}:${port}` : hostname;
|
||||
return WebRequest.get<CachedMinecraftServer>(
|
||||
return WebRequest.get<CachedJavaMinecraftServer | CachedBedrockMinecraftServer>(
|
||||
serverEndpoint.replace("{platform}", platform).replace("{hostname}", ip)
|
||||
);
|
||||
}
|
||||
@ -30,17 +34,30 @@ export function getServer(platform: ServerPlatform, hostname: string, port?: 255
|
||||
* @param port the port of the server
|
||||
* @returns the server icon, or null if the server does not have an icon
|
||||
*/
|
||||
export function getServerIcon(hostname: string, port?: 25565): Promise<Buffer> {
|
||||
export async function getServerIcon(hostname: string, port?: 25565): Promise<Buffer> {
|
||||
const ip = port ? `${hostname}:${port}` : hostname;
|
||||
return WebRequest.get<Buffer>(serverIconEndpoint.replace("{hostname}", ip));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preview of a Minecraft server's MOTD.
|
||||
*
|
||||
* @param platform the platform of the server
|
||||
* @param hostname the hostname of the server
|
||||
* @param port the port of the server
|
||||
* @returns the server icon, or null if the server does not have an icon
|
||||
*/
|
||||
export async function getServerPreview(platform: ServerPlatform, hostname: string, port?: 25565): Promise<Buffer> {
|
||||
const ip = port ? `${hostname}:${port}` : hostname;
|
||||
return WebRequest.get<Buffer>(serverPreviewEndpoint.replace("{platform}", platform).replace("{hostname}", ip));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Mojang blocked status of a Minecraft server.
|
||||
*
|
||||
* @param hostname the hostname of the server
|
||||
* @returns true if the server is blocked, false otherwise
|
||||
*/
|
||||
export function getBlockedStatus(hostname: string): Promise<BlockedStatus> {
|
||||
export async function getBlockedStatus(hostname: string): Promise<BlockedStatus> {
|
||||
return WebRequest.get<BlockedStatus>(blockedServerEndpoint.replace("{hostname}", hostname));
|
||||
}
|
||||
|
10
src/types/cache/cachedMinecraftServer.ts
vendored
10
src/types/cache/cachedMinecraftServer.ts
vendored
@ -1,10 +0,0 @@
|
||||
import BedrockMinecraftServer from "../server/bedrockServer";
|
||||
import JavaMinecraftServer from "../server/javaServer";
|
||||
import { Cache } from "./cache";
|
||||
|
||||
export interface CachedMinecraftServer extends Cache {
|
||||
/**
|
||||
* The cached server.
|
||||
*/
|
||||
server: JavaMinecraftServer | BedrockMinecraftServer;
|
||||
}
|
8
src/types/cache/cachedPlayer.ts
vendored
8
src/types/cache/cachedPlayer.ts
vendored
@ -1,8 +0,0 @@
|
||||
import { Player } from "../player/player";
|
||||
|
||||
export interface CachedPlayer extends Cache {
|
||||
/**
|
||||
* The cached player.
|
||||
*/
|
||||
player: Player;
|
||||
}
|
3
src/types/cache/cachedUsernameToUuid.ts
vendored
3
src/types/cache/cachedUsernameToUuid.ts
vendored
@ -1,3 +0,0 @@
|
||||
import { UsernameToUuid } from "../player/usernameToUuid";
|
||||
|
||||
export interface CachedUsernameToUuid extends Cache, UsernameToUuid {}
|
@ -1,4 +1,4 @@
|
||||
export type Error = {
|
||||
export type McUtilsAPIError = {
|
||||
/**
|
||||
* The status of the error.
|
||||
*/
|
||||
|
26
src/types/mojang/endpoint-status.ts
Normal file
26
src/types/mojang/endpoint-status.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import {Status} from "../status";
|
||||
import {Cache} from "../cache";
|
||||
|
||||
export interface EndpointStatuses extends EndpointStatus {
|
||||
/**
|
||||
* The endpoint statuses.
|
||||
*/
|
||||
endpoints: EndpointStatus[];
|
||||
}
|
||||
|
||||
type EndpointStatus = {
|
||||
/**
|
||||
* The name of the service.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The endpoint of the service.
|
||||
*/
|
||||
endpoint: string;
|
||||
|
||||
/**
|
||||
* The status of the service.
|
||||
*/
|
||||
status: Status;
|
||||
};
|
@ -1,4 +1,13 @@
|
||||
export type Player = {
|
||||
import {Cache} from "../cache";
|
||||
|
||||
export interface CachedPlayer extends Player {
|
||||
/**
|
||||
* The cache information.
|
||||
*/
|
||||
cache: Cache;
|
||||
}
|
||||
|
||||
type Player = {
|
||||
/**
|
||||
* The player's unique id.
|
||||
*/
|
||||
|
@ -1,4 +1,6 @@
|
||||
export type UsernameToUuid = {
|
||||
export interface CachedUsernameToUuid extends Cache, UsernameToUuid {}
|
||||
|
||||
type UsernameToUuid = {
|
||||
/**
|
||||
* The username of the player.
|
||||
*/
|
||||
|
@ -1,6 +1,14 @@
|
||||
import { MinecraftServer } from "./server";
|
||||
import {MinecraftServer} from "../server";
|
||||
import {Cache} from "../../cache";
|
||||
|
||||
export default interface BedrockMinecraftServer extends MinecraftServer {
|
||||
export interface CachedBedrockMinecraftServer extends BedrockMinecraftServer {
|
||||
/**
|
||||
* The cache information.
|
||||
*/
|
||||
cache: Cache;
|
||||
}
|
||||
|
||||
interface BedrockMinecraftServer extends MinecraftServer {
|
||||
/**
|
||||
* The edition of the server.
|
||||
*/
|
@ -1,6 +1,14 @@
|
||||
import { MinecraftServer } from "./server";
|
||||
import {MinecraftServer} from "../server";
|
||||
import {Cache} from "../../cache";
|
||||
|
||||
export default interface JavaMinecraftServer extends MinecraftServer {
|
||||
export interface CachedJavaMinecraftServer extends JavaMinecraftServer {
|
||||
/**
|
||||
* The cache information.
|
||||
*/
|
||||
cache: Cache;
|
||||
}
|
||||
|
||||
interface JavaMinecraftServer extends MinecraftServer {
|
||||
/**
|
||||
* The version of the server.
|
||||
*/
|
@ -28,6 +28,11 @@ export type MinecraftServer = {
|
||||
* The players on the server.
|
||||
*/
|
||||
players: Players;
|
||||
|
||||
/**
|
||||
* The location of the server, or undefined if the location is unknown.
|
||||
*/
|
||||
location?: GeoLocation;
|
||||
};
|
||||
|
||||
type Motd = {
|
||||
@ -45,6 +50,11 @@ type Motd = {
|
||||
* The HTML MOTD, with HTML tags for colors.
|
||||
*/
|
||||
html: string[];
|
||||
|
||||
/**
|
||||
* The server list MOTD preview.
|
||||
*/
|
||||
preview: string;
|
||||
};
|
||||
|
||||
type Players = {
|
||||
@ -75,3 +85,30 @@ type PlayerSample = {
|
||||
*/
|
||||
name: string;
|
||||
};
|
||||
|
||||
type GeoLocation = {
|
||||
/**
|
||||
* The country of the location.
|
||||
*/
|
||||
country: string;
|
||||
|
||||
/**
|
||||
* The region of the location.
|
||||
*/
|
||||
region: string;
|
||||
|
||||
/**
|
||||
* The city of the location.
|
||||
*/
|
||||
city: string;
|
||||
|
||||
/**
|
||||
* The latitude of the location.
|
||||
*/
|
||||
latitude: number;
|
||||
|
||||
/**
|
||||
* The longitude of the location.
|
||||
*/
|
||||
longitude: number;
|
||||
}
|
||||
|
@ -1,11 +1,4 @@
|
||||
export interface CachedEndpointStatus extends Cache {
|
||||
/**
|
||||
* The cached endpoint status.
|
||||
*/
|
||||
endpoints: Record<string, Status>;
|
||||
}
|
||||
|
||||
enum Status {
|
||||
export enum Status {
|
||||
/**
|
||||
* The service is online and operational.
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
import { getMojangEndpointStatus } from "../dist";
|
||||
import {getMojangEndpointStatus} from "../dist";
|
||||
|
||||
test("ensureMojangEndpointStatusLookupSuccess", async () => {
|
||||
const response = await getMojangEndpointStatus();
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { getPlayer, getPlayerSkinPart, getPlayerUuid } from "../dist/index";
|
||||
import {getPlayer, getPlayerSkinPart, getPlayerUuid} from "../dist/index";
|
||||
|
||||
test("ensureGetPlayerLookupSuccess", async () => {
|
||||
const response = await getPlayer("Notch");
|
||||
const { player } = response;
|
||||
const player = await getPlayer("Notch");
|
||||
|
||||
expect(player).toBeDefined();
|
||||
expect(player).toHaveProperty("username");
|
||||
@ -17,8 +16,7 @@ test("ensureGetPlayerUuidSuccess", async () => {
|
||||
});
|
||||
|
||||
test("ensureGetPlayerSkinPartSuccess", async () => {
|
||||
const response = await getPlayer("Notch");
|
||||
const { player } = response;
|
||||
const player = await getPlayer("Notch");
|
||||
|
||||
const skin = player.skin;
|
||||
const skinParts = skin.parts;
|
||||
@ -26,6 +24,7 @@ test("ensureGetPlayerSkinPartSuccess", async () => {
|
||||
// Test each skin part
|
||||
for (const part in skinParts) {
|
||||
const partBuffer = await getPlayerSkinPart(part, player.uniqueId);
|
||||
|
||||
expect(partBuffer).toBeDefined();
|
||||
expect(partBuffer.byteLength).toBeGreaterThan(0);
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
import { getBlockedStatus, getServer, getServerIcon } from "../dist";
|
||||
import { ServerPlatform } from "../src/types/server/platform";
|
||||
import {getBlockedStatus, getServer, getServerIcon, getServerPreview, ServerPlatform} from "../dist";
|
||||
|
||||
test("ensureGetServerLookupSuccess", async () => {
|
||||
const cachedServer = await getServer(ServerPlatform.Java, "mc.hypixel.net");
|
||||
const { server } = cachedServer;
|
||||
const server = await getServer(ServerPlatform.Java, "mc.hypixel.net");
|
||||
|
||||
expect(server).toBeDefined();
|
||||
expect(server).toHaveProperty("hostname"); // The server was found
|
||||
@ -11,6 +9,7 @@ test("ensureGetServerLookupSuccess", async () => {
|
||||
|
||||
test("ensureGetServerIconSuccess", async () => {
|
||||
const icon = await getServerIcon("mc.hypixel.net");
|
||||
|
||||
expect(icon).toBeDefined();
|
||||
expect(icon.byteLength).toBeGreaterThan(0); // The server has an icon
|
||||
});
|
||||
@ -21,3 +20,10 @@ test("ensureGetServerBlockedStatusSuccess", async () => {
|
||||
|
||||
expect(blocked).toBe(false); // The server is not blocked
|
||||
});
|
||||
|
||||
test("ensureGetServerPreviewSuccess", async () => {
|
||||
const preview = await getServerPreview(ServerPlatform.Java, "mc.hypixel.net");
|
||||
|
||||
expect(preview).toBeDefined();
|
||||
expect(preview.byteLength).toBeGreaterThan(0); // The server has a preview
|
||||
});
|
@ -3,7 +3,12 @@
|
||||
"module": "commonjs",
|
||||
"target": "ES2020",
|
||||
"declaration": true,
|
||||
"outDir": "./dist"
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"@/*": ["src/*"],
|
||||
"@types/*": ["src/types/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
Reference in New Issue
Block a user