mcutils-js-api 2.0.3 → 2.0.6

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
@@ -1,4 +1,5 @@
1
1
  import type { ErrorResponse } from "./types/response/error-response";
2
+ import type { IpLookupResponse } from "./types/response/ip-lookup-response";
2
3
  import type { BedrockServer } from "./types/server/impl/bedrock-server";
3
4
  import type { JavaServer } from "./types/server/impl/java-server";
4
5
  import type { CachedPlayer } from "./types/cache/cached-player";
@@ -43,6 +44,16 @@ export declare class McUtilsAPI {
43
44
  blocked?: boolean;
44
45
  error?: ErrorResponse;
45
46
  }>;
47
+ /**
48
+ * Look up IP address (geo + ASN).
49
+ *
50
+ * @param query the IP address to lookup (eg: 127.0.0.1)
51
+ * @returns the IP lookup response or the error (if one occurred)
52
+ */
53
+ fetchIpLookup(query: string): Promise<{
54
+ data?: IpLookupResponse;
55
+ error?: ErrorResponse;
56
+ }>;
46
57
  /**
47
58
  * Fetch a player by UUID or username.
48
59
  *
@@ -100,8 +111,8 @@ export declare class McUtilsAPI {
100
111
  *
101
112
  * @param id the UUID or username of the player (eg: ImFascinated)
102
113
  * @param part the skin part to fetch (eg: head)
103
- * @param size the image size (default: 256)
104
- * @param overlays whether to render skin overlay layers (default: false)
114
+ * @param size the image size (default: 768)
115
+ * @param overlays whether to render skin overlay layers (default: true)
105
116
  * @returns the skin part PNG image or the error (if one occurred)
106
117
  */
107
118
  fetchPlayerSkinPart(id: string, part: string, size?: number, overlays?: boolean): Promise<{
@@ -109,9 +120,9 @@ export declare class McUtilsAPI {
109
120
  error?: ErrorResponse;
110
121
  }>;
111
122
  /**
112
- * Fetch a player's cape image.
123
+ * Fetch a cape texture image by cape texture id.
113
124
  *
114
- * @param id the UUID or username of the player (eg: ImFascinated)
125
+ * @param id the cape texture id (eg: from player.cape or a texture hash)
115
126
  * @returns the cape PNG image or the error (if one occurred)
116
127
  */
117
128
  fetchPlayerCape(id: string): Promise<{
package/dist/index.js CHANGED
@@ -62,6 +62,21 @@ export class McUtilsAPI {
62
62
  error: (await response.json()),
63
63
  };
64
64
  }
65
+ /**
66
+ * Look up IP address (geo + ASN).
67
+ *
68
+ * @param query the IP address to lookup (eg: 127.0.0.1)
69
+ * @returns the IP lookup response or the error (if one occurred)
70
+ */
71
+ async fetchIpLookup(query) {
72
+ const response = await fetch(`${this.endpoint}/ip/${query}`);
73
+ if (response.ok) {
74
+ return { data: (await response.json()) };
75
+ }
76
+ return {
77
+ error: (await response.json()),
78
+ };
79
+ }
65
80
  /**
66
81
  * Fetch a player by UUID or username.
67
82
  *
@@ -135,7 +150,7 @@ export class McUtilsAPI {
135
150
  * @returns the skin PNG image or the error (if one occurred)
136
151
  */
137
152
  async fetchPlayerSkin(id) {
138
- const response = await fetch(`${this.endpoint}/skin/texture/${id}.png`);
153
+ const response = await fetch(`${this.endpoint}/skin/${id}/texture.png`);
139
154
  if (response.ok) {
140
155
  return { image: await response.arrayBuffer() };
141
156
  }
@@ -148,11 +163,11 @@ export class McUtilsAPI {
148
163
  *
149
164
  * @param id the UUID or username of the player (eg: ImFascinated)
150
165
  * @param part the skin part to fetch (eg: head)
151
- * @param size the image size (default: 256)
152
- * @param overlays whether to render skin overlay layers (default: false)
166
+ * @param size the image size (default: 768)
167
+ * @param overlays whether to render skin overlay layers (default: true)
153
168
  * @returns the skin part PNG image or the error (if one occurred)
154
169
  */
155
- async fetchPlayerSkinPart(id, part, size = 256, overlays = false) {
170
+ async fetchPlayerSkinPart(id, part, size = 768, overlays = true) {
156
171
  const response = await fetch(`${this.endpoint}/skin/${id}/${part}.png${this.buildParams({ size: String(size), overlays: String(overlays) })}`);
157
172
  if (response.ok) {
158
173
  return { image: await response.arrayBuffer() };
@@ -162,13 +177,13 @@ export class McUtilsAPI {
162
177
  };
163
178
  }
164
179
  /**
165
- * Fetch a player's cape image.
180
+ * Fetch a cape texture image by cape texture id.
166
181
  *
167
- * @param id the UUID or username of the player (eg: ImFascinated)
182
+ * @param id the cape texture id (eg: from player.cape or a texture hash)
168
183
  * @returns the cape PNG image or the error (if one occurred)
169
184
  */
170
185
  async fetchPlayerCape(id) {
171
- const response = await fetch(`${this.endpoint}/cape/texture/${id}.png`);
186
+ const response = await fetch(`${this.endpoint}/cape/${id}/texture.png`);
172
187
  if (response.ok) {
173
188
  return { image: await response.arrayBuffer() };
174
189
  }
package/dist/test.js CHANGED
@@ -4,5 +4,5 @@ api.fetchJavaServer("aetheria.cc").then((result) => {
4
4
  console.log(result);
5
5
  });
6
6
  api.fetchPlayer("ImFascinated").then((result) => {
7
- console.log(result);
7
+ console.log(result.player?.skin?.parts.FULLBODY_FRONT);
8
8
  });
@@ -0,0 +1,7 @@
1
+ import type { JavaServer } from "../server/impl/java-server";
2
+ import type { BedrockServer } from "../server/impl/bedrock-server";
3
+ /**
4
+ * Cached server response (backend returns cache fields + unwrapped server).
5
+ * Use JavaServer or BedrockServer for typed responses.
6
+ */
7
+ export type CachedMinecraftServer = JavaServer | BedrockServer;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,6 @@
1
1
  export type SkinModel = "DEFAULT" | "SLIM";
2
- export type SkinParts = Record<string, string>;
2
+ export type SkinPart = "HEAD" | "FULLBODY_FRONT" | "FULLBODY_BACK" | "FACE" | "BODY";
3
+ export type SkinParts = Record<SkinPart, string>;
3
4
  export type Skin = {
4
5
  model: SkinModel;
5
6
  legacy: boolean;
@@ -0,0 +1,7 @@
1
+ import type { GeoLocation } from "../server/server";
2
+ import type { AsnLookup } from "../server/server";
3
+ export type IpLookupResponse = {
4
+ ip: string;
5
+ location: GeoLocation | null;
6
+ asn: AsnLookup | null;
7
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export type ServerBlockedResponse = {
2
+ blocked: boolean;
3
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -16,7 +16,7 @@ export type ServerVersion = {
16
16
  protocolName: string;
17
17
  };
18
18
  export type ServerFavicon = {
19
- base64?: string;
19
+ base64: string;
20
20
  url: string;
21
21
  };
22
22
  export type ForgeModInfo = {
@@ -8,13 +8,14 @@ export interface Server extends Cache {
8
8
  players: ServerPlayers;
9
9
  records: DnsRecord[];
10
10
  location?: GeoLocation | null;
11
- asn?: AsnData | null;
11
+ asn?: AsnLookup | null;
12
12
  }
13
13
  export type ServerMotd = {
14
14
  raw: string[];
15
15
  clean: string[];
16
16
  html: string[];
17
17
  preview: string;
18
+ htmlPreview: string;
18
19
  };
19
20
  export type ServerPlayerSampleName = {
20
21
  raw: string;
@@ -40,7 +41,7 @@ export type GeoLocation = {
40
41
  longitude: number;
41
42
  flagUrl: string;
42
43
  };
43
- export type AsnData = {
44
+ export type AsnLookup = {
44
45
  asn: string;
45
46
  asnOrg: string;
46
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcutils-js-api",
3
- "version": "2.0.3",
3
+ "version": "2.0.6",
4
4
  "module": "dist/index.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",