mcutils-js-api 2.0.2 → 2.0.3

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
@@ -89,10 +89,9 @@ export declare class McUtilsAPI {
89
89
  * Fetch a player's skin image.
90
90
  *
91
91
  * @param id the UUID or username of the player (eg: ImFascinated)
92
- * @param extension the image format - png or jpg (default: png)
93
- * @returns the skin image or the error (if one occurred)
92
+ * @returns the skin PNG image or the error (if one occurred)
94
93
  */
95
- fetchPlayerSkin(id: string, extension?: string): Promise<{
94
+ fetchPlayerSkin(id: string): Promise<{
96
95
  image?: ArrayBuffer;
97
96
  error?: ErrorResponse;
98
97
  }>;
@@ -101,12 +100,21 @@ export declare class McUtilsAPI {
101
100
  *
102
101
  * @param id the UUID or username of the player (eg: ImFascinated)
103
102
  * @param part the skin part to fetch (eg: head)
104
- * @param extension the image format - png or jpg (default: png)
105
103
  * @param size the image size (default: 256)
106
104
  * @param overlays whether to render skin overlay layers (default: false)
107
- * @returns the skin part image or the error (if one occurred)
105
+ * @returns the skin part PNG image or the error (if one occurred)
108
106
  */
109
- fetchPlayerSkinPart(id: string, part: string, extension?: string, size?: number, overlays?: boolean): Promise<{
107
+ fetchPlayerSkinPart(id: string, part: string, size?: number, overlays?: boolean): Promise<{
108
+ image?: ArrayBuffer;
109
+ error?: ErrorResponse;
110
+ }>;
111
+ /**
112
+ * Fetch a player's cape image.
113
+ *
114
+ * @param id the UUID or username of the player (eg: ImFascinated)
115
+ * @returns the cape PNG image or the error (if one occurred)
116
+ */
117
+ fetchPlayerCape(id: string): Promise<{
110
118
  image?: ArrayBuffer;
111
119
  error?: ErrorResponse;
112
120
  }>;
package/dist/index.js CHANGED
@@ -132,11 +132,10 @@ export class McUtilsAPI {
132
132
  * Fetch a player's skin image.
133
133
  *
134
134
  * @param id the UUID or username of the player (eg: ImFascinated)
135
- * @param extension the image format - png or jpg (default: png)
136
- * @returns the skin image or the error (if one occurred)
135
+ * @returns the skin PNG image or the error (if one occurred)
137
136
  */
138
- async fetchPlayerSkin(id, extension = "png") {
139
- const response = await fetch(`${this.endpoint}/player/${id}/skin.${extension}`);
137
+ async fetchPlayerSkin(id) {
138
+ const response = await fetch(`${this.endpoint}/skin/texture/${id}.png`);
140
139
  if (response.ok) {
141
140
  return { image: await response.arrayBuffer() };
142
141
  }
@@ -149,13 +148,27 @@ export class McUtilsAPI {
149
148
  *
150
149
  * @param id the UUID or username of the player (eg: ImFascinated)
151
150
  * @param part the skin part to fetch (eg: head)
152
- * @param extension the image format - png or jpg (default: png)
153
151
  * @param size the image size (default: 256)
154
152
  * @param overlays whether to render skin overlay layers (default: false)
155
- * @returns the skin part image or the error (if one occurred)
153
+ * @returns the skin part PNG image or the error (if one occurred)
156
154
  */
157
- async fetchPlayerSkinPart(id, part, extension = "png", size = 256, overlays = false) {
158
- const response = await fetch(`${this.endpoint}/player/${id}/skin/${part}.${extension}${this.buildParams({ size: String(size), overlays: String(overlays) })}`);
155
+ async fetchPlayerSkinPart(id, part, size = 256, overlays = false) {
156
+ const response = await fetch(`${this.endpoint}/skin/${id}/${part}.png${this.buildParams({ size: String(size), overlays: String(overlays) })}`);
157
+ if (response.ok) {
158
+ return { image: await response.arrayBuffer() };
159
+ }
160
+ return {
161
+ error: (await response.json()),
162
+ };
163
+ }
164
+ /**
165
+ * Fetch a player's cape image.
166
+ *
167
+ * @param id the UUID or username of the player (eg: ImFascinated)
168
+ * @returns the cape PNG image or the error (if one occurred)
169
+ */
170
+ async fetchPlayerCape(id) {
171
+ const response = await fetch(`${this.endpoint}/cape/texture/${id}.png`);
159
172
  if (response.ok) {
160
173
  return { image: await response.arrayBuffer() };
161
174
  }
@@ -3,11 +3,11 @@ export type SkinParts = Record<string, string>;
3
3
  export type Skin = {
4
4
  model: SkinModel;
5
5
  legacy: boolean;
6
- url: string;
6
+ textureUrl: string;
7
7
  parts: SkinParts;
8
8
  };
9
9
  export type Cape = {
10
- id?: string;
10
+ textureUrl: string;
11
11
  };
12
12
  export type ProfileProperty = {
13
13
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcutils-js-api",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "module": "dist/index.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",