mcutils-js-api 2.0.25 → 2.0.26
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 +11 -0
- package/dist/index.js +15 -0
- package/dist/test.js +1 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { CachedPlayer } from "./types/cache/cached-player";
|
|
|
6
6
|
import type { CachedPlayerName } from "./types/cache/cached-player-name";
|
|
7
7
|
import type { ServerPlatform } from "./types/server/server";
|
|
8
8
|
import type { Cape } from "./types/player/cape/cape";
|
|
9
|
+
import { ServerRegistryEntry } from "./types/server-registry/server-registry-entry";
|
|
9
10
|
export declare class McUtilsAPI {
|
|
10
11
|
private readonly endpoint;
|
|
11
12
|
constructor(endpoint?: string);
|
|
@@ -163,5 +164,15 @@ export declare class McUtilsAPI {
|
|
|
163
164
|
image?: ArrayBuffer;
|
|
164
165
|
error?: ErrorResponse;
|
|
165
166
|
}>;
|
|
167
|
+
/**
|
|
168
|
+
* Fetch the list of available server registry entries.
|
|
169
|
+
*
|
|
170
|
+
* @param query the query to search for (eg: aetheria)
|
|
171
|
+
* @returns the list of server registry entries or the error (if one occurred)
|
|
172
|
+
*/
|
|
173
|
+
fetchServerRegistryEntries(query: string): Promise<{
|
|
174
|
+
entries?: ServerRegistryEntry[];
|
|
175
|
+
error?: ErrorResponse;
|
|
176
|
+
}>;
|
|
166
177
|
}
|
|
167
178
|
export default McUtilsAPI;
|
package/dist/index.js
CHANGED
|
@@ -240,5 +240,20 @@ export class McUtilsAPI {
|
|
|
240
240
|
error: (await response.json()),
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Fetch the list of available server registry entries.
|
|
245
|
+
*
|
|
246
|
+
* @param query the query to search for (eg: aetheria)
|
|
247
|
+
* @returns the list of server registry entries or the error (if one occurred)
|
|
248
|
+
*/
|
|
249
|
+
async fetchServerRegistryEntries(query) {
|
|
250
|
+
const response = await fetch(`${this.endpoint}/servers${this.buildParams({ query: query })}`);
|
|
251
|
+
if (response.ok) {
|
|
252
|
+
return { entries: (await response.json()) };
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
error: (await response.json()),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
243
258
|
}
|
|
244
259
|
export default McUtilsAPI;
|
package/dist/test.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import McUtilsAPI from ".";
|
|
2
2
|
const api = new McUtilsAPI();
|
|
3
|
-
api.
|
|
3
|
+
api.fetchServerRegistryEntries("wild").then((result) => {
|
|
4
4
|
console.log(result);
|
|
5
5
|
});
|
|
6
|
-
api.fetchPlayer("ImFascinated").then((result) => {
|
|
7
|
-
console.log(result.player?.skin?.parts.FULLBODY_FRONT);
|
|
8
|
-
});
|