mcutils-js-api 2.0.18 → 2.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -0
- package/dist/index.js +27 -13
- package/dist/types/player/cape/cape-part.d.ts +1 -0
- package/dist/types/player/cape/cape.d.ts +9 -0
- package/dist/types/player/cape/cape.js +1 -0
- package/dist/types/player/player.d.ts +3 -15
- package/dist/types/player/profile-property.d.ts +5 -0
- package/dist/types/player/profile-property.js +1 -0
- package/dist/types/player/skin/skin-model.d.ts +1 -0
- package/dist/types/player/skin/skin-model.js +1 -0
- package/dist/types/player/skin/skin-part.d.ts +1 -0
- package/dist/types/player/skin/skin-part.js +1 -0
- package/dist/types/player/skin/skin.d.ts +8 -0
- package/dist/types/player/skin/skin.js +1 -0
- package/package.json +1 -1
- package/dist/types/cape/cape.d.ts +0 -5
- /package/dist/types/{cape/cape.js → player/cape/cape-part.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { BedrockServer } from "./types/server/impl/bedrock-server";
|
|
|
4
4
|
import type { JavaServer } from "./types/server/impl/java-server";
|
|
5
5
|
import type { CachedPlayer } from "./types/cache/cached-player";
|
|
6
6
|
import type { CachedPlayerName } from "./types/cache/cached-player-name";
|
|
7
|
+
import type { CapeData } from "./types/player/cape/cape";
|
|
7
8
|
import { ServerType } from "./types/server/server";
|
|
8
9
|
export declare class McUtilsAPI {
|
|
9
10
|
private readonly endpoint;
|
|
@@ -131,6 +132,15 @@ export declare class McUtilsAPI {
|
|
|
131
132
|
image?: ArrayBuffer;
|
|
132
133
|
error?: ErrorResponse;
|
|
133
134
|
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Fetch the list of available capes (e.g. Migrator).
|
|
137
|
+
*
|
|
138
|
+
* @returns the list of cape data or the error (if one occurred)
|
|
139
|
+
*/
|
|
140
|
+
fetchCapes(): Promise<{
|
|
141
|
+
capes?: CapeData[];
|
|
142
|
+
error?: ErrorResponse;
|
|
143
|
+
}>;
|
|
134
144
|
/**
|
|
135
145
|
* Fetch a cape texture image.
|
|
136
146
|
*
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export class McUtilsAPI {
|
|
|
20
20
|
* @returns the server or the error (if one occurred)
|
|
21
21
|
*/
|
|
22
22
|
async fetchServer(host, type) {
|
|
23
|
-
const response = await fetch(`${this.endpoint}/
|
|
23
|
+
const response = await fetch(`${this.endpoint}/servers/${type}/${host}`);
|
|
24
24
|
if (response.ok) {
|
|
25
25
|
return {
|
|
26
26
|
server: (await response.json()),
|
|
@@ -37,7 +37,7 @@ export class McUtilsAPI {
|
|
|
37
37
|
* @returns the server or the error (if one occurred)
|
|
38
38
|
*/
|
|
39
39
|
async fetchJavaServer(host) {
|
|
40
|
-
const response = await fetch(`${this.endpoint}/
|
|
40
|
+
const response = await fetch(`${this.endpoint}/servers/java/${host}`);
|
|
41
41
|
if (response.ok) {
|
|
42
42
|
return {
|
|
43
43
|
server: (await response.json()),
|
|
@@ -54,7 +54,7 @@ export class McUtilsAPI {
|
|
|
54
54
|
* @returns the server or the error (if one occurred)
|
|
55
55
|
*/
|
|
56
56
|
async fetchBedrockServer(host) {
|
|
57
|
-
const response = await fetch(`${this.endpoint}/
|
|
57
|
+
const response = await fetch(`${this.endpoint}/servers/bedrock/${host}`);
|
|
58
58
|
if (response.ok) {
|
|
59
59
|
return {
|
|
60
60
|
server: (await response.json()),
|
|
@@ -71,7 +71,7 @@ export class McUtilsAPI {
|
|
|
71
71
|
* @returns the blocked status or the error (if one occurred)
|
|
72
72
|
*/
|
|
73
73
|
async fetchServerBlocked(host) {
|
|
74
|
-
const response = await fetch(`${this.endpoint}/
|
|
74
|
+
const response = await fetch(`${this.endpoint}/servers/blocked/${host}`);
|
|
75
75
|
if (response.ok) {
|
|
76
76
|
const json = (await response.json());
|
|
77
77
|
return { blocked: json.blocked };
|
|
@@ -87,7 +87,7 @@ export class McUtilsAPI {
|
|
|
87
87
|
* @returns the IP lookup response or the error (if one occurred)
|
|
88
88
|
*/
|
|
89
89
|
async fetchIpLookup(query) {
|
|
90
|
-
const response = await fetch(`${this.endpoint}/
|
|
90
|
+
const response = await fetch(`${this.endpoint}/ips/${query}`);
|
|
91
91
|
if (response.ok) {
|
|
92
92
|
return { data: (await response.json()) };
|
|
93
93
|
}
|
|
@@ -102,7 +102,7 @@ export class McUtilsAPI {
|
|
|
102
102
|
* @returns the player or the error (if one occurred)
|
|
103
103
|
*/
|
|
104
104
|
async fetchPlayer(id) {
|
|
105
|
-
const response = await fetch(`${this.endpoint}/
|
|
105
|
+
const response = await fetch(`${this.endpoint}/players/${id}`);
|
|
106
106
|
if (response.ok) {
|
|
107
107
|
return {
|
|
108
108
|
player: (await response.json()),
|
|
@@ -119,7 +119,7 @@ export class McUtilsAPI {
|
|
|
119
119
|
* @returns the player name data or the error (if one occurred)
|
|
120
120
|
*/
|
|
121
121
|
async fetchPlayerUuid(id) {
|
|
122
|
-
const response = await fetch(`${this.endpoint}/
|
|
122
|
+
const response = await fetch(`${this.endpoint}/players/uuid/${id}`);
|
|
123
123
|
if (response.ok) {
|
|
124
124
|
return {
|
|
125
125
|
playerName: (await response.json()),
|
|
@@ -136,7 +136,7 @@ export class McUtilsAPI {
|
|
|
136
136
|
* @returns the PNG image or the error (if one occurred)
|
|
137
137
|
*/
|
|
138
138
|
async fetchServerIcon(host) {
|
|
139
|
-
const response = await fetch(`${this.endpoint}/
|
|
139
|
+
const response = await fetch(`${this.endpoint}/servers/icon/${host}`);
|
|
140
140
|
if (response.ok) {
|
|
141
141
|
return { image: await response.arrayBuffer() };
|
|
142
142
|
}
|
|
@@ -153,7 +153,7 @@ export class McUtilsAPI {
|
|
|
153
153
|
* @returns the PNG image or the error (if one occurred)
|
|
154
154
|
*/
|
|
155
155
|
async fetchServerPreview(platform, host, size = 768) {
|
|
156
|
-
const response = await fetch(`${this.endpoint}/
|
|
156
|
+
const response = await fetch(`${this.endpoint}/servers/${platform}/preview/${host}${this.buildParams({ size: String(size) })}`);
|
|
157
157
|
if (response.ok) {
|
|
158
158
|
return { image: await response.arrayBuffer() };
|
|
159
159
|
}
|
|
@@ -168,7 +168,7 @@ export class McUtilsAPI {
|
|
|
168
168
|
* @returns the skin PNG image or the error (if one occurred)
|
|
169
169
|
*/
|
|
170
170
|
async fetchPlayerSkinTexture(id) {
|
|
171
|
-
const response = await fetch(`${this.endpoint}/
|
|
171
|
+
const response = await fetch(`${this.endpoint}/skins/${id}/texture.png`);
|
|
172
172
|
if (response.ok) {
|
|
173
173
|
return { image: await response.arrayBuffer() };
|
|
174
174
|
}
|
|
@@ -186,7 +186,7 @@ export class McUtilsAPI {
|
|
|
186
186
|
* @returns the skin part PNG image or the error (if one occurred)
|
|
187
187
|
*/
|
|
188
188
|
async fetchPlayerSkin(id, part, size = 768, overlays = true) {
|
|
189
|
-
const response = await fetch(`${this.endpoint}/
|
|
189
|
+
const response = await fetch(`${this.endpoint}/skins/${id}/${part}.png${this.buildParams({ size: String(size), overlays: String(overlays) })}`);
|
|
190
190
|
if (response.ok) {
|
|
191
191
|
return { image: await response.arrayBuffer() };
|
|
192
192
|
}
|
|
@@ -194,6 +194,20 @@ export class McUtilsAPI {
|
|
|
194
194
|
error: (await response.json()),
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Fetch the list of available capes (e.g. Migrator).
|
|
199
|
+
*
|
|
200
|
+
* @returns the list of cape data or the error (if one occurred)
|
|
201
|
+
*/
|
|
202
|
+
async fetchCapes() {
|
|
203
|
+
const response = await fetch(`${this.endpoint}/capes`);
|
|
204
|
+
if (response.ok) {
|
|
205
|
+
return { capes: (await response.json()) };
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
error: (await response.json()),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
197
211
|
/**
|
|
198
212
|
* Fetch a cape texture image.
|
|
199
213
|
*
|
|
@@ -201,7 +215,7 @@ export class McUtilsAPI {
|
|
|
201
215
|
* @returns the cape PNG image or the error (if one occurred)
|
|
202
216
|
*/
|
|
203
217
|
async fetchCapeTexture(query) {
|
|
204
|
-
const response = await fetch(`${this.endpoint}/
|
|
218
|
+
const response = await fetch(`${this.endpoint}/capes/${query}/texture.png`);
|
|
205
219
|
if (response.ok) {
|
|
206
220
|
return { image: await response.arrayBuffer() };
|
|
207
221
|
}
|
|
@@ -218,7 +232,7 @@ export class McUtilsAPI {
|
|
|
218
232
|
* @returns the cape part PNG image or the error (if one occurred)
|
|
219
233
|
*/
|
|
220
234
|
async fetchCapePart(query, type, size = 768) {
|
|
221
|
-
const response = await fetch(`${this.endpoint}/
|
|
235
|
+
const response = await fetch(`${this.endpoint}/capes/${query}/${type}.png${this.buildParams({ size: String(size) })}`);
|
|
222
236
|
if (response.ok) {
|
|
223
237
|
return { image: await response.arrayBuffer() };
|
|
224
238
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CapePart = "FRONT";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import { Cape } from "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type SkinParts = Record<SkinPart, string>;
|
|
5
|
-
export type Skin = {
|
|
6
|
-
model: SkinModel;
|
|
7
|
-
legacy: boolean;
|
|
8
|
-
textureUrl: string;
|
|
9
|
-
parts: SkinParts;
|
|
10
|
-
};
|
|
11
|
-
export type ProfileProperty = {
|
|
12
|
-
name: string;
|
|
13
|
-
value: string;
|
|
14
|
-
signature?: string;
|
|
15
|
-
};
|
|
1
|
+
import { Cape } from "./cape/cape";
|
|
2
|
+
import { ProfileProperty } from "./profile-property";
|
|
3
|
+
import { Skin } from "./skin/skin";
|
|
16
4
|
export type Player = {
|
|
17
5
|
uniqueId: string;
|
|
18
6
|
username: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SkinModel = "DEFAULT" | "SLIM";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SkinPart = "HEAD" | "FULLBODY_FRONT" | "FULLBODY_BACK" | "FACE" | "BODY";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
File without changes
|