This commit is contained in:
59
src/app/(pages)/globals.css
Normal file
59
src/app/(pages)/globals.css
Normal file
@ -0,0 +1,59 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--background: 0 0% 100%;
|
||||
--foreground: 240 10% 3.9%;
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 240 10% 3.9%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 240 10% 3.9%;
|
||||
--primary: 142.1 76.2% 36.3%;
|
||||
--primary-foreground: 355.7 100% 97.3%;
|
||||
--secondary: 240 4.8% 95.9%;
|
||||
--secondary-foreground: 240 5.9% 10%;
|
||||
--muted: 240 4.8% 95.9%;
|
||||
--muted-foreground: 240 3.8% 46.1%;
|
||||
--accent: 240 4.8% 95.9%;
|
||||
--accent-foreground: 240 5.9% 10%;
|
||||
--destructive: 0 84.2% 60.2%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--border: 240 5.9% 90%;
|
||||
--input: 240 5.9% 90%;
|
||||
--ring: 142.1 76.2% 36.3%;
|
||||
--radius: 0.5rem;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: 20 14.3% 4.1%;
|
||||
--foreground: 0 0% 95%;
|
||||
--card: 24 9.8% 10%;
|
||||
--card-foreground: 0 0% 95%;
|
||||
--popover: 0 0% 9%;
|
||||
--popover-foreground: 0 0% 95%;
|
||||
--primary: 142.1 70.6% 45.3%;
|
||||
--primary-foreground: 144.9 80.4% 10%;
|
||||
--secondary: 240 3.7% 15.9%;
|
||||
--secondary-foreground: 0 0% 98%;
|
||||
--muted: 0 0% 15%;
|
||||
--muted-foreground: 240 5% 64.9%;
|
||||
--accent: 12 6.5% 15.1%;
|
||||
--accent-foreground: 0 0% 98%;
|
||||
--destructive: 0 62.8% 30.6%;
|
||||
--destructive-foreground: 0 85.7% 97.3%;
|
||||
--border: 240 3.7% 15.9%;
|
||||
--input: 240 3.7% 15.9%;
|
||||
--ring: 142.4 71.8% 29.2%;
|
||||
}
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
51
src/app/(pages)/layout.tsx
Normal file
51
src/app/(pages)/layout.tsx
Normal file
@ -0,0 +1,51 @@
|
||||
import { Fonts } from "@/common/fonts";
|
||||
import { Metadata, Viewport } from "next";
|
||||
import { ToastContainer } from "react-toastify";
|
||||
|
||||
import "react-toastify/dist/ReactToastify.css";
|
||||
import "./globals.css";
|
||||
|
||||
import Config from "../../../config.json";
|
||||
import Container from "../components/container";
|
||||
import ThemeProvider from "../components/theme-provider";
|
||||
|
||||
export const viewport: Viewport = {
|
||||
themeColor: "#3498DB",
|
||||
};
|
||||
|
||||
export const metadata: Metadata = {
|
||||
metadataBase: new URL(Config.siteUrl),
|
||||
title: {
|
||||
template: Config.siteName + " - %s",
|
||||
default: Config.siteName,
|
||||
},
|
||||
description: Config.siteDescription,
|
||||
keywords: "Minecraft, APIs, wrapper, utility, development",
|
||||
openGraph: {
|
||||
title: Config.siteName,
|
||||
description: Config.siteDescription,
|
||||
url: Config.siteUrl,
|
||||
locale: "en_US",
|
||||
type: "website",
|
||||
},
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<>
|
||||
<html className={Fonts.inter.className} lang="en" suppressHydrationWarning>
|
||||
<head />
|
||||
<body>
|
||||
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem>
|
||||
<ToastContainer theme="dark" pauseOnFocusLoss={false} />
|
||||
<Container>{children}</Container>
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
</>
|
||||
);
|
||||
}
|
40
src/app/(pages)/page.tsx
Normal file
40
src/app/(pages)/page.tsx
Normal file
@ -0,0 +1,40 @@
|
||||
import Link from "next/link";
|
||||
|
||||
type Button = {
|
||||
title: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
const buttons: Button[] = [
|
||||
{ title: "Get Started", url: "/player/Notch" },
|
||||
{ title: "Documentation", url: "https://api.mcutils.xyz/swagger-ui.html" },
|
||||
];
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="text-center flex flex-col justify-center">
|
||||
<h1 className="text-4xl mb-2">Minecraft Utilities</h1>
|
||||
<div className="text-lg">
|
||||
<p>Minecraft Utilities offers you many endpoints to get information about a minecraft server or a player.</p>
|
||||
<p>
|
||||
You can use this information on your minecraft server or website. We offer you a simple and easy to use API.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 flex flex-row gap-2 justify-center">
|
||||
{buttons.map((button, index) => {
|
||||
return (
|
||||
<Link
|
||||
key={index}
|
||||
href={button.url}
|
||||
target="_blank"
|
||||
className="w-fit p-2 rounded-lg hover:text-primary transition-all cursor-pointer bg-secondary"
|
||||
>
|
||||
<p>{button.title}</p>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
93
src/app/(pages)/player/[id]/page.tsx
Normal file
93
src/app/(pages)/player/[id]/page.tsx
Normal file
@ -0,0 +1,93 @@
|
||||
import { NotFound } from "@/app/components/not-found";
|
||||
import { LookupPlayer } from "@/app/components/player/lookup-player";
|
||||
import { Card } from "@/app/components/ui/card";
|
||||
import { generateEmbed } from "@/common/embed";
|
||||
import { getPlayer } from "mcutils-library";
|
||||
import { Player } from "mcutils-library/dist/types/player/player";
|
||||
import { Metadata } from "next";
|
||||
import Image from "next/image";
|
||||
|
||||
type Params = {
|
||||
params: {
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
|
||||
export async function generateMetadata({ params: { id } }: Params): Promise<Metadata> {
|
||||
const player = await getData(id);
|
||||
if (player == null) {
|
||||
return generateEmbed({ title: "Unknown Player", description: "Player not found" });
|
||||
}
|
||||
|
||||
const { username, uniqueId, skin } = player;
|
||||
const headPartUrl = skin.parts.head;
|
||||
|
||||
const description = `
|
||||
Username: ${username}
|
||||
UUID: ${uniqueId}`;
|
||||
|
||||
return generateEmbed({
|
||||
title: `${username}`,
|
||||
description: description,
|
||||
image: headPartUrl,
|
||||
});
|
||||
}
|
||||
|
||||
async function getData(id: string): Promise<Player | null> {
|
||||
try {
|
||||
const cachedPlayer = await getPlayer(id);
|
||||
return cachedPlayer.player;
|
||||
} catch (error) {
|
||||
return null; // Player not found
|
||||
}
|
||||
}
|
||||
|
||||
export default async function Page({ params }: Params) {
|
||||
const player = await getData(params.id);
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col items-center">
|
||||
<div className="mb-4 text-center">
|
||||
<h1 className="text-xl">Lookup a Player</h1>
|
||||
<p>You can enter a players uuid or username to get information about the player.</p>
|
||||
|
||||
<LookupPlayer />
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
{player == null && <NotFound message="Player not found" />}
|
||||
{player != null && (
|
||||
<div className="flex gap-2 flex-col md:flex-row">
|
||||
<div className="flex justify-center md:justify-start">
|
||||
<Image
|
||||
className="w-[96px] h-[96px]"
|
||||
src={player.skin.parts.head}
|
||||
width={96}
|
||||
height={96}
|
||||
alt="The player's skin"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<div>
|
||||
<h2 className="text-xl">{player.username}</h2>
|
||||
<p className="text-gray-300">{player.uniqueId}</p>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<p className="text-lg">Skin Parts</p>
|
||||
<div className="flex gap-2">
|
||||
{Object.entries(player.skin.parts).map(([key, value]) => {
|
||||
return (
|
||||
<img className="h-[64px]" key={key} src={value} alt={`The player's ${key}`} loading="lazy" />
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
100
src/app/(pages)/server/[platform]/[hostname]/page.tsx
Normal file
100
src/app/(pages)/server/[platform]/[hostname]/page.tsx
Normal file
@ -0,0 +1,100 @@
|
||||
import { NotFound } from "@/app/components/not-found";
|
||||
import { LookupServer } from "@/app/components/server/lookup-server";
|
||||
import { Card } from "@/app/components/ui/card";
|
||||
import { generateEmbed } from "@/common/embed";
|
||||
import { capitalizeFirstLetter } from "@/common/string-utils";
|
||||
import { getServer } from "mcutils-library";
|
||||
import JavaMinecraftServer from "mcutils-library/dist/types/server/javaServer";
|
||||
import { ServerPlatform } from "mcutils-library/dist/types/server/platform";
|
||||
import { MinecraftServer } from "mcutils-library/dist/types/server/server";
|
||||
import { Metadata } from "next";
|
||||
import Image from "next/image";
|
||||
|
||||
type Params = {
|
||||
params: {
|
||||
platform: ServerPlatform;
|
||||
hostname: string;
|
||||
};
|
||||
};
|
||||
|
||||
export async function generateMetadata({ params: { platform, hostname } }: Params): Promise<Metadata> {
|
||||
const server = await getData(platform, hostname);
|
||||
if (server == null) {
|
||||
return generateEmbed({ title: "Unknown Server", description: "Server not found" });
|
||||
}
|
||||
|
||||
const { hostname: serverHostname, players } = server;
|
||||
|
||||
let favicon = null; // Server favicon
|
||||
|
||||
// Java specific
|
||||
if (platform === ServerPlatform.Java) {
|
||||
const javaServer = server as JavaMinecraftServer;
|
||||
favicon = javaServer.favicon && javaServer.favicon.url;
|
||||
}
|
||||
|
||||
const description = `
|
||||
${capitalizeFirstLetter(platform)} Server
|
||||
Hostname: ${serverHostname}
|
||||
${players.online}/${players.max} players online`;
|
||||
|
||||
return generateEmbed({
|
||||
title: `${serverHostname}`,
|
||||
description: description,
|
||||
image: favicon,
|
||||
});
|
||||
}
|
||||
|
||||
async function getData(platform: ServerPlatform, id: string): Promise<MinecraftServer | null> {
|
||||
try {
|
||||
const cachedServer = await getServer(platform, id);
|
||||
return cachedServer.server;
|
||||
} catch (error) {
|
||||
return null; // Server not found
|
||||
}
|
||||
}
|
||||
|
||||
export default async function Page({ params: { platform, hostname } }: Params) {
|
||||
const server = await getData(platform, hostname);
|
||||
|
||||
let favicon = null; // Server favicon
|
||||
|
||||
// Java specific
|
||||
if (server && platform === ServerPlatform.Java) {
|
||||
const javaServer = server as JavaMinecraftServer;
|
||||
favicon = javaServer.favicon && javaServer.favicon.url;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col items-center">
|
||||
<div className="mb-4 text-center">
|
||||
<h1 className="text-xl">Lookup a {capitalizeFirstLetter(platform)} Server</h1>
|
||||
<p>You can enter a server hostname to get information about the server.</p>
|
||||
|
||||
<LookupServer />
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
{server == null && <NotFound message="Server not found" />}
|
||||
{server != null && (
|
||||
<div className="flex gap-2 flex-col md:flex-row">
|
||||
{favicon && (
|
||||
<div className="flex justify-center md:justify-start">
|
||||
<Image className="w-[96px] h-[96px]" src={favicon} width={96} height={96} alt="The server's favicon" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex flex-col">
|
||||
<h2 className="text-xl">{server.hostname}</h2>
|
||||
<div className="text-gray-300">
|
||||
<p>
|
||||
Players online: {server.players.online}/{server.players.max}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user