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 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}/server/${type}/${host}`);
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}/server/java/${host}`);
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}/server/bedrock/${host}`);
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}/server/blocked/${host}`);
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}/ip/${query}`);
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}/player/${id}`);
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}/player/uuid/${id}`);
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}/server/icon/${host}`);
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}/server/${platform}/preview/${host}${this.buildParams({ size: String(size) })}`);
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}/skin/${id}/texture.png`);
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}/skin/${id}/${part}.png${this.buildParams({ size: String(size), overlays: String(overlays) })}`);
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}/cape/${query}/texture.png`);
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}/cape/${query}/${type}.png${this.buildParams({ size: String(size) })}`);
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,9 @@
1
+ import { CapePart } from "./cape-part";
2
+ export type Cape = {
3
+ textureUrl: string;
4
+ parts: Record<CapePart, string>;
5
+ };
6
+ export type CapeData = {
7
+ name: string;
8
+ textureId: string;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,18 +1,6 @@
1
- import { Cape } from "../cape/cape";
2
- export type SkinModel = "DEFAULT" | "SLIM";
3
- export type SkinPart = "HEAD" | "FULLBODY_FRONT" | "FULLBODY_BACK" | "FACE" | "BODY";
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,5 @@
1
+ export type ProfileProperty = {
2
+ name: string;
3
+ value: string;
4
+ signature?: string;
5
+ };
@@ -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,8 @@
1
+ import { SkinModel } from "./skin-model";
2
+ import { SkinPart } from "./skin-part";
3
+ export type Skin = {
4
+ model: SkinModel;
5
+ legacy: boolean;
6
+ textureUrl: string;
7
+ parts: Record<SkinPart, string>;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcutils-js-api",
3
- "version": "2.0.18",
3
+ "version": "2.0.20",
4
4
  "module": "dist/index.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,5 +0,0 @@
1
- export type CapeRendererType = "FRONT";
2
- export type Cape = {
3
- textureUrl: string;
4
- parts: Record<string, string>;
5
- };