JS SDK: Add Geo and query data to servers
Some checks failed
Publish JS SDK / docker (push) Failing after 18s

This commit is contained in:
Braydon 2024-04-26 17:00:40 -04:00
parent 856e445182
commit 9d594a8c37
11 changed files with 118 additions and 37 deletions

@ -1,11 +1,11 @@
import { WebRequest } from "@/lib/web-request";
import { HttpMethod } from "@/types/http-method";
import { MojangServerStatusResponse } from "@/types/mojang/server-status-response";
import { CachedPlayer } from "@/types/player/player";
import { SkinPart } from "@/types/player/skin-part";
import { CachedBedrockMinecraftServer } from "@/types/server/bedrock/server";
import { CachedJavaMinecraftServer } from "@/types/server/java-server";
import { ServerPlatform } from "@/types/server/platform";
import {WebRequest} from "@/lib/web-request";
import {HttpMethod} from "@/types/http-method";
import {MojangServerStatusResponse} from "@/types/mojang/server-status-response";
import {CachedPlayer} from "@/types/player/player";
import {SkinPart} from "@/types/player/skin-part";
import {CachedBedrockMinecraftServer} from "@/types/server/bedrock/server";
import {CachedJavaMinecraftServer} from "@/types/server/java-server";
import {ServerPlatform} from "@/types/server/platform";
/**
* Get a player by their username or UUID.

@ -1,5 +1,5 @@
import { RestfulMCAPIError } from "@/types/error";
import { HttpMethod } from "@/types/http-method";
import {RestfulMCAPIError} from "@/types/error";
import {HttpMethod} from "@/types/http-method";
const API_ENDPOINT = "https://api.restfulmc.cc"; // The API endpoint to use

@ -1,4 +1,4 @@
import { RecordType } from "@/type/dns/record-type";
import {RecordType} from "@/type/dns/record-type";
/**
* An A record.

@ -1,4 +1,4 @@
import { MojangServerStatus } from "@/types/mojang/server-status";
import {MojangServerStatus} from "@/types/mojang/server-status";
/**
* Represents the status of

@ -1,6 +1,6 @@
import { ProfileAction } from "@/types/player/profile-action";
import { SkinModel } from "@/types/player/skin-model";
import { SkinPart } from "@/types/player/skin-part";
import {ProfileAction} from "@/types/player/profile-action";
import {SkinModel} from "@/types/player/skin-model";
import {SkinPart} from "@/types/player/skin-part";
/**
* A cacheable {@link Player}.

@ -1,5 +1,5 @@
import { Edition } from "@/types/server/bedrock/edition";
import { MinecraftServer } from "@/types/server/server";
import {Edition} from "@/types/server/bedrock/edition";
import {MinecraftServer} from "@/types/server/server";
/**
* A cacheable {@link BedrockMinecraftServer}.

@ -1,4 +1,4 @@
import { MinecraftServer } from "@/types/server/server";
import {MinecraftServer} from "@/types/server/server";
/**
* A cacheable {@link JavaMinecraftServer}.
@ -25,6 +25,17 @@ export interface JavaMinecraftServer extends MinecraftServer {
*/
favicon?: Favicon | undefined;
/**
* The software of this server, present if query is on.
*/
software?: string | undefined;
/**
* The plugins on this server, present if
* query is on and plugins are present.
*/
plugins?: Plugin[] | undefined;
/**
* The Forge mod information for this server, undefined if none.
* <p>
@ -41,6 +52,16 @@ export interface JavaMinecraftServer extends MinecraftServer {
*/
forgeData?: ForgeData | undefined;
/**
* The main world of this server, present if query is on.
*/
world?: string | undefined;
/**
* Does this server support querying?
*/
queryEnabled: boolean;
/**
* Does this server preview chat?
*
@ -112,6 +133,21 @@ type Favicon = {
url: string;
};
/**
* A plugin for a server.
*/
type Plugin = {
/**
* The name of this plugin.
*/
name: string;
/**
* The version of this plugin.
*/
version: string;
};
/**
* Forge mod information for a server.
* <p>

@ -1,4 +1,4 @@
import { ARecord, SRVRecord } from "@/types/dns/dns-record";
import {ARecord, SRVRecord} from "@/types/dns/dns-record";
/**
* A model representing a Minecraft server.
@ -24,6 +24,11 @@ export type MinecraftServer = {
*/
records: ARecord | SRVRecord[];
/**
* The Geo location of this server, undefined if unknown.
*/
geo?: GeoLocation | undefined;
/**
* The player counts of this server.
*/
@ -35,6 +40,51 @@ export type MinecraftServer = {
motd: MOTD;
};
/**
* The Geo location of a server.
*/
type GeoLocation = {
/**
* The continent of this server.
*/
continent: LocationData;
/**
* The country of this server.
*/
country: LocationData;
/**
* The city of this server, undefined if unknown.
*/
city?: string | undefined;
/**
* The latitude of this server.
*/
latitude: number;
/**
* The longitude of this server.
*/
longitude: number;
}
/**
* Data for a location.
*/
type LocationData = {
/**
* The location code.
*/
code: string;
/**
* The location name.
*/
name: string;
}
/**
* Player count data for a server.
*/

@ -1,6 +1,6 @@
import { getMojangServerStatus } from "@/index";
import { MojangServerStatusResponse } from "@/types/mojang/server-status-response";
import { expect, test } from "bun:test";
import {getMojangServerStatus} from "@/index";
import {MojangServerStatusResponse} from "@/types/mojang/server-status-response";
import {expect, test} from "bun:test";
/**
* Run a test to ensure retrieving

@ -1,8 +1,8 @@
import { getPlayer, getSkinPart } from "@/index";
import { RestfulMCAPIError } from "@/types/error";
import { CachedPlayer } from "@/types/player/player";
import { SkinPart } from "@/types/player/skin-part";
import { expect, test } from "bun:test";
import {getPlayer, getSkinPart} from "@/index";
import {RestfulMCAPIError} from "@/types/error";
import {CachedPlayer} from "@/types/player/player";
import {SkinPart} from "@/types/player/skin-part";
import {expect, test} from "bun:test";
/**
* Run a test to ensure retrieving

@ -1,13 +1,8 @@
import {
ServerPlatform,
getJavaServerFavicon,
getMinecraftServer,
isMojangBlocked,
} from "@/index";
import { RestfulMCAPIError } from "@/types/error";
import { CachedBedrockMinecraftServer } from "@/types/server/bedrock/server";
import { CachedJavaMinecraftServer } from "@/types/server/java-server";
import { expect, test } from "bun:test";
import {getJavaServerFavicon, getMinecraftServer, isMojangBlocked, ServerPlatform,} from "@/index";
import {RestfulMCAPIError} from "@/types/error";
import {CachedBedrockMinecraftServer} from "@/types/server/bedrock/server";
import {CachedJavaMinecraftServer} from "@/types/server/java-server";
import {expect, test} from "bun:test";
/**
* Run a test to ensure retrieving a