diff --git a/public/media/platform/bedrock.png b/public/media/platform/bedrock.png new file mode 100644 index 0000000..4b4feb8 Binary files /dev/null and b/public/media/platform/bedrock.png differ diff --git a/public/media/platform/java.png b/public/media/platform/java.png new file mode 100644 index 0000000..3036471 Binary files /dev/null and b/public/media/platform/java.png differ diff --git a/src/app/(pages)/page.tsx b/src/app/(pages)/page.tsx index d80593f..7f79731 100644 --- a/src/app/(pages)/page.tsx +++ b/src/app/(pages)/page.tsx @@ -5,36 +5,9 @@ import { Button } from "../components/ui/button"; import { Separator } from "../components/ui/separator"; import { Tooltip, TooltipContent, TooltipTrigger } from "../components/ui/tooltip"; import { Title } from "@/app/components/title"; +import { LandingButton } from "@/app/types/landing/landing-button"; -type Button = { - /** - * The title of the button. - */ - title: string; - - /** - * The tooltip to display for this statistic. - */ - tooltip: string; - - /** - * The URL to go to. - */ - url: string; - - /** - * Whether clicking the button will - * open the link in a new tab. - */ - openInNewTab?: boolean; - - /** - * The class name to apply to the button. - */ - className?: string; -}; - -const buttons: Button[] = [ +const buttons: LandingButton[] = [ { title: "Get Started", tooltip: "Click to get started with the API", diff --git a/src/app/(pages)/player/[[...id]]/page.tsx b/src/app/(pages)/player/[[...id]]/page.tsx index 1552a3d..42cd48a 100644 --- a/src/app/(pages)/player/[[...id]]/page.tsx +++ b/src/app/(pages)/player/[[...id]]/page.tsx @@ -12,23 +12,23 @@ import { CachedPlayer, getPlayer, McUtilsAPIError } from "mcutils-library"; import { Metadata, Viewport } from "next"; import { ReactElement } from "react"; import { Title } from "@/app/components/title"; +import { Card } from "@/app/components/card"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@/app/components/ui/tooltip"; +import Link from "next/link"; +import Image from "next/image"; +import { PlayerPageParams } from "@/app/types/player/page-params"; +import { TryAPlayer } from "@/app/components/player/try-a-player"; export const revalidate = 60; -type Params = { - params: { - id: string; - }; -}; - -export async function generateViewport({ params: { id } }: Params): Promise { +export async function generateViewport({ params: { id } }: PlayerPageParams): Promise { const validPlayer = await isValidPlayer(id); return { themeColor: validPlayer ? Colors.green : Colors.red, }; } -export async function generateMetadata({ params: { id } }: Params): Promise { +export async function generateMetadata({ params: { id } }: PlayerPageParams): Promise { // No id provided if (!id || id.length === 0) { return generateEmbed({ @@ -55,7 +55,7 @@ export async function generateMetadata({ params: { id } }: Params): Promise { +export default async function Page({ params: { id } }: PlayerPageParams): Promise { let error: string | undefined = undefined; // The error to display let player: CachedPlayer | undefined = undefined; // The player to display @@ -98,6 +98,9 @@ export default async function Page({ params: { id } }: Params): Promise )} + + {/* Try a Player */} + {player == null && !error && } ); } diff --git a/src/app/(pages)/server/[platform]/[[...hostname]]/page.tsx b/src/app/(pages)/server/[platform]/[[...hostname]]/page.tsx index 4994e59..615d2e7 100644 --- a/src/app/(pages)/server/[platform]/[[...hostname]]/page.tsx +++ b/src/app/(pages)/server/[platform]/[[...hostname]]/page.tsx @@ -5,7 +5,6 @@ import { ServerView } from "@/app/components/server/server-view"; import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "@/app/components/ui/context-menu"; import { Colors } from "@/app/common/colors"; import { generateEmbed } from "@/app/common/embed"; -import { formatNumber } from "@/app/common/number-utils"; import { isValidServer } from "@/app/common/server"; import { capitalizeFirstLetter } from "@/app/common/string-utils"; import config from "@root/config.json"; @@ -19,16 +18,16 @@ import { import { Metadata, Viewport } from "next"; import { ReactElement } from "react"; import { Title } from "@/app/components/title"; +import { Card } from "@/app/components/card"; +import Link from "next/link"; +import Image from "next/image"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@/app/components/ui/tooltip"; +import { TryMeServer } from "@/app/types/server/try-me-server"; +import { ServerPageParams } from "@/app/types/server/page-params"; +import { TryAServer } from "@/app/components/server/try-a-server"; export const revalidate = 60; -type Params = { - params: { - platform: ServerPlatform; - hostname: string; - }; -}; - /** * Gets the favicon for a server * @@ -57,14 +56,14 @@ function checkPlatform(platform: ServerPlatform): boolean { return platform === ServerPlatform.Java || platform === ServerPlatform.Bedrock; } -export async function generateViewport({ params: { platform, hostname } }: Params): Promise { +export async function generateViewport({ params: { platform, hostname } }: ServerPageParams): Promise { const validPlayer = await isValidServer(platform, hostname); return { themeColor: validPlayer || !platform ? Colors.green : Colors.red, }; } -export async function generateMetadata({ params: { platform, hostname } }: Params): Promise { +export async function generateMetadata({ params: { platform, hostname } }: ServerPageParams): Promise { if (!checkPlatform(platform)) { // Invalid platform return generateEmbed({ @@ -100,7 +99,7 @@ export async function generateMetadata({ params: { platform, hostname } }: Param } } -export default async function Page({ params: { platform, hostname } }: Params): Promise { +export default async function Page({ params: { platform, hostname } }: ServerPageParams): Promise { let error: string | undefined = undefined; // The error to display let server: CachedJavaMinecraftServer | CachedBedrockMinecraftServer | undefined = undefined; // The server to display let invalidPlatform: boolean = !checkPlatform(platform); // Whether the platform is invalid @@ -129,7 +128,10 @@ export default async function Page({ params: { platform, hostname } }: Params): + {/* An errored occurred when looking up the server */} {error && } + + {/* The server */} {server != null && ( @@ -147,6 +149,9 @@ export default async function Page({ params: { platform, hostname } }: Params): )} + + {/* Try a Server */} + {server == null && !error && } ); } diff --git a/src/app/components/player/try-a-player.tsx b/src/app/components/player/try-a-player.tsx new file mode 100644 index 0000000..e754e07 --- /dev/null +++ b/src/app/components/player/try-a-player.tsx @@ -0,0 +1,49 @@ +import { ReactElement } from "react"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@/app/components/ui/tooltip"; +import Image from "next/image"; +import config from "@root/config.json"; +import Link from "next/link"; +import { Card } from "@/app/components/card"; + +/** + * The players to try out. + */ +const tryMePlayers: string[] = ["Notch", "jeb_", "Dinnerbone", "Grumm", "Mojang"]; + +export function TryAPlayer(): ReactElement { + return ( + +
+
+

Try a Player

+

Try one of these players to see how the player view works.

+
+ +
+ {tryMePlayers.map(playerName => ( + + +
+ {"The + + {playerName} + +
+
+ +

+ Click to try the player {playerName}. +

+
+
+ ))} +
+
+
+ ); +} diff --git a/src/app/components/server/try-a-server.tsx b/src/app/components/server/try-a-server.tsx new file mode 100644 index 0000000..19bdbd4 --- /dev/null +++ b/src/app/components/server/try-a-server.tsx @@ -0,0 +1,54 @@ +import { ReactElement } from "react"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@/app/components/ui/tooltip"; +import Image from "next/image"; +import Link from "next/link"; +import { capitalizeFirstLetter } from "@/app/common/string-utils"; +import { Card } from "@/app/components/card"; +import { ServerPlatform } from "mcutils-library"; +import { TryMeServer } from "@/app/types/server/try-me-server"; + +/** + * The servers to try out. + */ +const tryMeServers: TryMeServer[] = [ + { platform: ServerPlatform.Java, hostname: "mc.hypixel.net" }, + { platform: ServerPlatform.Java, hostname: "wildprison.net" }, + { platform: ServerPlatform.Java, hostname: "cubecraft.net" }, + { platform: ServerPlatform.Bedrock, hostname: "geo.hivebedrock.network" }, +]; + +export function TryAServer(): ReactElement { + return ( + +
+
+

Try a Server

+

Try one of these servers to see how the server view works.

+
+ +
+ {tryMeServers.map(({ platform, hostname }) => ( + + +
+ {"The + + {hostname} + +
+
+ +

+ Click to try the {capitalizeFirstLetter(platform)} server: {hostname} +

+
+
+ ))} +
+
+
+ ); +} diff --git a/src/app/types/landing/landing-button.tsx b/src/app/types/landing/landing-button.tsx new file mode 100644 index 0000000..245641a --- /dev/null +++ b/src/app/types/landing/landing-button.tsx @@ -0,0 +1,27 @@ +export type LandingButton = { + /** + * The title of the button. + */ + title: string; + + /** + * The tooltip to display for this statistic. + */ + tooltip: string; + + /** + * The URL to go to. + */ + url: string; + + /** + * Whether clicking the button will + * open the link in a new tab. + */ + openInNewTab?: boolean; + + /** + * The class name to apply to the button. + */ + className?: string; +}; diff --git a/src/app/types/player/page-params.ts b/src/app/types/player/page-params.ts new file mode 100644 index 0000000..1a1648f --- /dev/null +++ b/src/app/types/player/page-params.ts @@ -0,0 +1,5 @@ +export type PlayerPageParams = { + params: { + id: string; + }; +}; diff --git a/src/app/types/server/page-params.ts b/src/app/types/server/page-params.ts new file mode 100644 index 0000000..06fc758 --- /dev/null +++ b/src/app/types/server/page-params.ts @@ -0,0 +1,8 @@ +import { ServerPlatform } from "mcutils-library"; + +export type ServerPageParams = { + params: { + platform: ServerPlatform; + hostname: string; + }; +}; diff --git a/src/app/types/server/try-me-server.ts b/src/app/types/server/try-me-server.ts new file mode 100644 index 0000000..208852c --- /dev/null +++ b/src/app/types/server/try-me-server.ts @@ -0,0 +1,13 @@ +import { ServerPlatform } from "mcutils-library"; + +export type TryMeServer = { + /** + * The platform of the server. + */ + platform: ServerPlatform; + + /** + * The hostname of the server. + */ + hostname: string; +};