mcutils-js-api 1.0.0 → 1.0.2
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 +17 -0
- package/dist/types/server/bedrock-server.d.ts +15 -0
- package/dist/types/server/bedrock-server.js +2 -0
- package/dist/types/server/java-server.d.ts +0 -1
- package/dist/types/server/server.d.ts +1 -16
- package/dist/types/server/server.js +0 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ErrorResponse } from "./types/response/error-response";
|
|
2
|
+
import { BedrockServer } from "./types/server/bedrock-server";
|
|
2
3
|
import type { JavaServer } from "./types/server/java-server";
|
|
3
4
|
/**
|
|
4
5
|
* Fetch a Java Minecraft server.
|
|
@@ -10,3 +11,13 @@ export declare function fetchJavaServer(host: string): Promise<{
|
|
|
10
11
|
server?: JavaServer;
|
|
11
12
|
error?: ErrorResponse;
|
|
12
13
|
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Fetch a Bedrock Minecraft server.
|
|
16
|
+
*
|
|
17
|
+
* @param host the host to fetch the server using (eg: geo.hivebedrock.network)
|
|
18
|
+
* @returns the server or the error (if one occured)
|
|
19
|
+
*/
|
|
20
|
+
export declare function fetchBedrockServer(host: string): Promise<{
|
|
21
|
+
server?: BedrockServer;
|
|
22
|
+
error?: ErrorResponse;
|
|
23
|
+
}>;
|
package/dist/index.js
CHANGED
|
@@ -16,3 +16,20 @@ export async function fetchJavaServer(host) {
|
|
|
16
16
|
error: (await response.json()),
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Fetch a Bedrock Minecraft server.
|
|
21
|
+
*
|
|
22
|
+
* @param host the host to fetch the server using (eg: geo.hivebedrock.network)
|
|
23
|
+
* @returns the server or the error (if one occured)
|
|
24
|
+
*/
|
|
25
|
+
export async function fetchBedrockServer(host) {
|
|
26
|
+
const response = await fetch(`${API_BASE}/server/bedrock/${host}`);
|
|
27
|
+
if (response.ok) {
|
|
28
|
+
return {
|
|
29
|
+
server: (await response.json()),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
error: (await response.json()),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Server } from "./server";
|
|
2
|
+
export interface BedrockServer extends Server {
|
|
3
|
+
edition: ServerEdition;
|
|
4
|
+
version: ServerVersion;
|
|
5
|
+
gamemode: ServerGamemode;
|
|
6
|
+
}
|
|
7
|
+
export type ServerEdition = "MCPE" | "MCEE";
|
|
8
|
+
export type ServerVersion = {
|
|
9
|
+
protocol: number;
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export type ServerGamemode = {
|
|
13
|
+
name: string;
|
|
14
|
+
numericId: number;
|
|
15
|
+
};
|
|
@@ -6,14 +6,8 @@ export interface Server extends Cache {
|
|
|
6
6
|
motd: ServerMotd;
|
|
7
7
|
players: ServerPlayers;
|
|
8
8
|
records: Array<DnsRecord>;
|
|
9
|
-
version: ServerVersion;
|
|
10
|
-
favicon: ServerFavicon;
|
|
11
|
-
preventsChatReports: boolean;
|
|
12
|
-
enforcesSecureChat: boolean;
|
|
13
|
-
previewsChat: boolean;
|
|
14
9
|
location: ServerLocation;
|
|
15
10
|
asn: AsnData;
|
|
16
|
-
mojangBlocked: boolean;
|
|
17
11
|
}
|
|
18
12
|
export type ServerMotd = {
|
|
19
13
|
raw: string[];
|
|
@@ -29,18 +23,9 @@ export type DnsRecord = {
|
|
|
29
23
|
ttl: number;
|
|
30
24
|
address: string;
|
|
31
25
|
};
|
|
32
|
-
export type ServerVersion = {
|
|
33
|
-
name: string;
|
|
34
|
-
platform: string;
|
|
35
|
-
protocol: number;
|
|
36
|
-
protocolName: string;
|
|
37
|
-
};
|
|
38
|
-
export type ServerFavicon = {
|
|
39
|
-
base64: string;
|
|
40
|
-
url: string;
|
|
41
|
-
};
|
|
42
26
|
export type ServerLocation = {
|
|
43
27
|
country: string;
|
|
28
|
+
countryCode: string;
|
|
44
29
|
region: string;
|
|
45
30
|
latitude: number;
|
|
46
31
|
longitude: number;
|