2026-04-13 00:46:58 -06:00
|
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
|
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
|
|
|
import { useState } from "react";
|
UX polish pass 2: toasts, optimistic updates, mod update detection
- Install sonner; <Toaster> mounted in Providers, auto-tracks theme.
- Toasts replace inline result Alerts across ServerControls, PlayerManager,
BackupManager, ModManager (install/remove/restore/delete/start/stop).
- PlayerManager: optimistic op/deop/whitelist/ban/pardon via onMutate +
rollback; UI updates instantly before RCON round-trip.
- Modrinth search results now show author + "updated Xd ago" with full
timestamp on hover; downloads on its own row.
- New /api/mods/updates endpoint: per-installed-mod Modrinth latest-version
lookup (parallel, 30min memo). Amber "Update available" badge rendered
next to installed mod rows when filenames differ.
- PlayerAvatar + Modrinth icons migrated to next/image (unoptimized, size
hints) — fewer layout shifts.
- Login page surfaces ?error= + NextAuth error codes (CredentialsSignin,
SessionRequired, etc.), preserves callbackUrl, adds autocomplete hints
and role="alert". Wrapped in Suspense per Next 16 requirement.
- Snapshots + backups show relative "Xh ago" with exact timestamp on hover
via new lib/time.ts helper.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 05:11:17 -06:00
|
|
|
|
import { toast } from "sonner";
|
2026-04-13 00:46:58 -06:00
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
|
|
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
|
|
import { Separator } from "@/components/ui/separator";
|
|
|
|
|
|
import {
|
|
|
|
|
|
Card,
|
|
|
|
|
|
CardContent,
|
|
|
|
|
|
CardDescription,
|
|
|
|
|
|
CardHeader,
|
|
|
|
|
|
CardTitle,
|
|
|
|
|
|
} from "@/components/ui/card";
|
2026-04-13 00:51:35 -06:00
|
|
|
|
import { PlayerAvatar } from "@/components/PlayerAvatar";
|
Rich per-player stats + pick-your-metric leaderboard
- lib/player-stats.ts: single computePlayerStats() reads every
world/stats/<uuid>.json plus world/advancements/<uuid>.json and joins
with usercache.json. Returns a flat PlayerStats record per player:
playtime, longest life, mob/player kills, deaths, K/D, damage dealt
and taken (HP-scaled), blocks mined, items used / crafted / picked up
(+ unique), distance (summed across all _one_cm stats), chest opens,
nether/end trips, villager trades, fish caught, animals bred, and
advancements (non-recipe) / recipes unlocked.
- New GET /api/players/stats (authed, 60s memo). Existing
/api/players/playtime now returns a thin projection of the same
computed data (shared cache key keeps both endpoints cheap).
- New components/Leaderboard.tsx with a metric select grouped into
Time / Combat / World / Exploration / Progression / Economy (22
metrics). Sorts descending, top 10 with "show all" toggle, smart
number formatting (1.2k / 3.4M / HP / km). Replaces the old
PlaytimeLeaderboard in the Players tab.
- PlayerDrawer upgraded: uses the full stats payload, shows small
tiles for Kills / Deaths / K/D / Advs / Mined / Crafted / Distance
alongside Playtime + Last seen.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 06:37:50 -06:00
|
|
|
|
import { Leaderboard } from "@/components/Leaderboard";
|
2026-04-13 00:46:58 -06:00
|
|
|
|
|
|
|
|
|
|
type PlayerData = {
|
|
|
|
|
|
ops: { name: string; uuid: string; level: number }[];
|
|
|
|
|
|
whitelist: { name: string; uuid: string }[];
|
|
|
|
|
|
banned: { name: string; uuid: string; reason: string }[];
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
type Tab = "ops" | "whitelist" | "banned";
|
|
|
|
|
|
|
|
|
|
|
|
export function PlayerManager() {
|
|
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
|
|
const [tab, setTab] = useState<Tab>("ops");
|
|
|
|
|
|
const [playerName, setPlayerName] = useState("");
|
|
|
|
|
|
const [banReason, setBanReason] = useState("");
|
|
|
|
|
|
|
|
|
|
|
|
const { data = { ops: [], whitelist: [], banned: [] } } = useQuery<PlayerData>({
|
|
|
|
|
|
queryKey: ["players"],
|
|
|
|
|
|
queryFn: async () => {
|
|
|
|
|
|
const res = await fetch("/api/players");
|
|
|
|
|
|
if (!res.ok) throw new Error("Failed to fetch players");
|
|
|
|
|
|
return res.json();
|
|
|
|
|
|
},
|
|
|
|
|
|
staleTime: 10_000,
|
|
|
|
|
|
refetchInterval: 15_000,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const action = useMutation({
|
|
|
|
|
|
mutationFn: async (params: { action: string; player: string; reason?: string }) => {
|
|
|
|
|
|
const res = await fetch("/api/players", {
|
|
|
|
|
|
method: "POST",
|
|
|
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
|
|
|
body: JSON.stringify(params),
|
|
|
|
|
|
});
|
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
|
if (!res.ok) throw new Error(data.error);
|
|
|
|
|
|
return data;
|
|
|
|
|
|
},
|
UX polish pass 2: toasts, optimistic updates, mod update detection
- Install sonner; <Toaster> mounted in Providers, auto-tracks theme.
- Toasts replace inline result Alerts across ServerControls, PlayerManager,
BackupManager, ModManager (install/remove/restore/delete/start/stop).
- PlayerManager: optimistic op/deop/whitelist/ban/pardon via onMutate +
rollback; UI updates instantly before RCON round-trip.
- Modrinth search results now show author + "updated Xd ago" with full
timestamp on hover; downloads on its own row.
- New /api/mods/updates endpoint: per-installed-mod Modrinth latest-version
lookup (parallel, 30min memo). Amber "Update available" badge rendered
next to installed mod rows when filenames differ.
- PlayerAvatar + Modrinth icons migrated to next/image (unoptimized, size
hints) — fewer layout shifts.
- Login page surfaces ?error= + NextAuth error codes (CredentialsSignin,
SessionRequired, etc.), preserves callbackUrl, adds autocomplete hints
and role="alert". Wrapped in Suspense per Next 16 requirement.
- Snapshots + backups show relative "Xh ago" with exact timestamp on hover
via new lib/time.ts helper.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 05:11:17 -06:00
|
|
|
|
onMutate: async (params) => {
|
|
|
|
|
|
await queryClient.cancelQueries({ queryKey: ["players"] });
|
|
|
|
|
|
const prev = queryClient.getQueryData<PlayerData>(["players"]);
|
|
|
|
|
|
if (prev) {
|
|
|
|
|
|
const next: PlayerData = {
|
|
|
|
|
|
ops: [...prev.ops],
|
|
|
|
|
|
whitelist: [...prev.whitelist],
|
|
|
|
|
|
banned: [...prev.banned],
|
|
|
|
|
|
};
|
|
|
|
|
|
const name = params.player;
|
|
|
|
|
|
switch (params.action) {
|
|
|
|
|
|
case "op":
|
|
|
|
|
|
if (!next.ops.some((p) => p.name === name))
|
|
|
|
|
|
next.ops.push({ name, uuid: "", level: 4 });
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "deop":
|
|
|
|
|
|
next.ops = next.ops.filter((p) => p.name !== name);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "whitelist add":
|
|
|
|
|
|
if (!next.whitelist.some((p) => p.name === name))
|
|
|
|
|
|
next.whitelist.push({ name, uuid: "" });
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "whitelist remove":
|
|
|
|
|
|
next.whitelist = next.whitelist.filter((p) => p.name !== name);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "ban":
|
|
|
|
|
|
if (!next.banned.some((p) => p.name === name))
|
|
|
|
|
|
next.banned.push({ name, uuid: "", reason: params.reason || "" });
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "pardon":
|
|
|
|
|
|
next.banned = next.banned.filter((p) => p.name !== name);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
queryClient.setQueryData(["players"], next);
|
|
|
|
|
|
}
|
|
|
|
|
|
return { prev };
|
|
|
|
|
|
},
|
2026-04-13 00:46:58 -06:00
|
|
|
|
onSuccess: (data) => {
|
UX polish pass 2: toasts, optimistic updates, mod update detection
- Install sonner; <Toaster> mounted in Providers, auto-tracks theme.
- Toasts replace inline result Alerts across ServerControls, PlayerManager,
BackupManager, ModManager (install/remove/restore/delete/start/stop).
- PlayerManager: optimistic op/deop/whitelist/ban/pardon via onMutate +
rollback; UI updates instantly before RCON round-trip.
- Modrinth search results now show author + "updated Xd ago" with full
timestamp on hover; downloads on its own row.
- New /api/mods/updates endpoint: per-installed-mod Modrinth latest-version
lookup (parallel, 30min memo). Amber "Update available" badge rendered
next to installed mod rows when filenames differ.
- PlayerAvatar + Modrinth icons migrated to next/image (unoptimized, size
hints) — fewer layout shifts.
- Login page surfaces ?error= + NextAuth error codes (CredentialsSignin,
SessionRequired, etc.), preserves callbackUrl, adds autocomplete hints
and role="alert". Wrapped in Suspense per Next 16 requirement.
- Snapshots + backups show relative "Xh ago" with exact timestamp on hover
via new lib/time.ts helper.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 05:11:17 -06:00
|
|
|
|
toast.success(data.response || "Done");
|
2026-04-13 00:46:58 -06:00
|
|
|
|
setPlayerName("");
|
|
|
|
|
|
setBanReason("");
|
|
|
|
|
|
},
|
UX polish pass 2: toasts, optimistic updates, mod update detection
- Install sonner; <Toaster> mounted in Providers, auto-tracks theme.
- Toasts replace inline result Alerts across ServerControls, PlayerManager,
BackupManager, ModManager (install/remove/restore/delete/start/stop).
- PlayerManager: optimistic op/deop/whitelist/ban/pardon via onMutate +
rollback; UI updates instantly before RCON round-trip.
- Modrinth search results now show author + "updated Xd ago" with full
timestamp on hover; downloads on its own row.
- New /api/mods/updates endpoint: per-installed-mod Modrinth latest-version
lookup (parallel, 30min memo). Amber "Update available" badge rendered
next to installed mod rows when filenames differ.
- PlayerAvatar + Modrinth icons migrated to next/image (unoptimized, size
hints) — fewer layout shifts.
- Login page surfaces ?error= + NextAuth error codes (CredentialsSignin,
SessionRequired, etc.), preserves callbackUrl, adds autocomplete hints
and role="alert". Wrapped in Suspense per Next 16 requirement.
- Snapshots + backups show relative "Xh ago" with exact timestamp on hover
via new lib/time.ts helper.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 05:11:17 -06:00
|
|
|
|
onError: (err, _vars, ctx) => {
|
|
|
|
|
|
if (ctx?.prev) queryClient.setQueryData(["players"], ctx.prev);
|
|
|
|
|
|
toast.error("Action failed", { description: err.message });
|
|
|
|
|
|
},
|
|
|
|
|
|
onSettled: () => {
|
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: ["players"] });
|
2026-04-13 00:46:58 -06:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const tabs: { key: Tab; label: string; count: number }[] = [
|
|
|
|
|
|
{ key: "ops", label: "Operators", count: data.ops.length },
|
|
|
|
|
|
{ key: "whitelist", label: "Whitelist", count: data.whitelist.length },
|
|
|
|
|
|
{ key: "banned", label: "Banned", count: data.banned.length },
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const MC_NAME_RE = /^[A-Za-z0-9_]{3,16}$/;
|
|
|
|
|
|
const trimmed = playerName.trim();
|
|
|
|
|
|
const nameValid = MC_NAME_RE.test(trimmed);
|
|
|
|
|
|
const nameError =
|
|
|
|
|
|
trimmed.length === 0
|
|
|
|
|
|
? null
|
|
|
|
|
|
: !nameValid
|
|
|
|
|
|
? "3–16 chars, letters/numbers/underscores only"
|
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
const handleAction = (act: string, player?: string) => {
|
|
|
|
|
|
const name = player || trimmed;
|
|
|
|
|
|
if (!name) return;
|
|
|
|
|
|
if (!player && !nameValid) return;
|
|
|
|
|
|
action.mutate({ action: act, player: name, reason: banReason || undefined });
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
Per-player playtime tracking + sparkline hover tooltips
- New GET /api/players/playtime (authed): reads each vanilla stats file
under /home/minecraft/server/world/stats and maps uuid→name via
usercache.json. Returns playtime in ticks and hours, plus file mtime
as "last seen". Memoized 60s via lib/cache#memoAsync.
- New PlaytimeLeaderboard card in the Players tab:
- Rank, avatar (click → PlayerDrawer), relative last-seen, hours.
- Top 10 by default with toggle to show all; combined hours badge.
- PlayerDrawer surfaces the player's total hours + last-seen using the
same cached playtime query, plus fills in UUID if the player is not
in ops/whitelist/banned.
- lib/time.ts: formatHours() — minutes under 1h, "H.Hh" under a day,
"Dd Hh" above.
- Analytics sparklines gain hover/touch tooltips:
- Timestamps threaded through from each MetricEntry.
- SVG overlay captures onMouseMove/onTouchMove, computes nearest
index by x, draws a dashed guide line + focus dot.
- Floating tooltip shows HH:MM + formatted value with unit; edge
clamping keeps it in-frame at the extremes.
- Per-chart formatValue so RAM shows GB, CPU 0 decimals, Players
integer, TPS 1 decimal. Keeps the peak-player marker intact.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 06:24:13 -06:00
|
|
|
|
<div className="space-y-4 sm:space-y-6">
|
Rich per-player stats + pick-your-metric leaderboard
- lib/player-stats.ts: single computePlayerStats() reads every
world/stats/<uuid>.json plus world/advancements/<uuid>.json and joins
with usercache.json. Returns a flat PlayerStats record per player:
playtime, longest life, mob/player kills, deaths, K/D, damage dealt
and taken (HP-scaled), blocks mined, items used / crafted / picked up
(+ unique), distance (summed across all _one_cm stats), chest opens,
nether/end trips, villager trades, fish caught, animals bred, and
advancements (non-recipe) / recipes unlocked.
- New GET /api/players/stats (authed, 60s memo). Existing
/api/players/playtime now returns a thin projection of the same
computed data (shared cache key keeps both endpoints cheap).
- New components/Leaderboard.tsx with a metric select grouped into
Time / Combat / World / Exploration / Progression / Economy (22
metrics). Sorts descending, top 10 with "show all" toggle, smart
number formatting (1.2k / 3.4M / HP / km). Replaces the old
PlaytimeLeaderboard in the Players tab.
- PlayerDrawer upgraded: uses the full stats payload, shows small
tiles for Kills / Deaths / K/D / Advs / Mined / Crafted / Distance
alongside Playtime + Last seen.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 06:37:50 -06:00
|
|
|
|
<Leaderboard />
|
2026-04-13 00:46:58 -06:00
|
|
|
|
<Card>
|
|
|
|
|
|
<CardHeader>
|
|
|
|
|
|
<CardTitle>Player Management</CardTitle>
|
|
|
|
|
|
<CardDescription>
|
|
|
|
|
|
Manage operators, whitelist, and bans via RCON
|
|
|
|
|
|
</CardDescription>
|
|
|
|
|
|
</CardHeader>
|
|
|
|
|
|
<CardContent className="space-y-4">
|
|
|
|
|
|
{/* Tabs */}
|
|
|
|
|
|
<div className="flex gap-1 bg-muted p-1 rounded-lg">
|
|
|
|
|
|
{tabs.map((t) => (
|
|
|
|
|
|
<button
|
|
|
|
|
|
key={t.key}
|
UX polish pass 2: toasts, optimistic updates, mod update detection
- Install sonner; <Toaster> mounted in Providers, auto-tracks theme.
- Toasts replace inline result Alerts across ServerControls, PlayerManager,
BackupManager, ModManager (install/remove/restore/delete/start/stop).
- PlayerManager: optimistic op/deop/whitelist/ban/pardon via onMutate +
rollback; UI updates instantly before RCON round-trip.
- Modrinth search results now show author + "updated Xd ago" with full
timestamp on hover; downloads on its own row.
- New /api/mods/updates endpoint: per-installed-mod Modrinth latest-version
lookup (parallel, 30min memo). Amber "Update available" badge rendered
next to installed mod rows when filenames differ.
- PlayerAvatar + Modrinth icons migrated to next/image (unoptimized, size
hints) — fewer layout shifts.
- Login page surfaces ?error= + NextAuth error codes (CredentialsSignin,
SessionRequired, etc.), preserves callbackUrl, adds autocomplete hints
and role="alert". Wrapped in Suspense per Next 16 requirement.
- Snapshots + backups show relative "Xh ago" with exact timestamp on hover
via new lib/time.ts helper.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 05:11:17 -06:00
|
|
|
|
onClick={() => setTab(t.key)}
|
2026-04-13 00:46:58 -06:00
|
|
|
|
className={`flex-1 px-2 sm:px-3 py-2 rounded-md text-xs sm:text-sm font-medium transition min-h-[40px] ${
|
|
|
|
|
|
tab === t.key
|
|
|
|
|
|
? "bg-background text-foreground shadow-sm"
|
|
|
|
|
|
: "text-muted-foreground hover:text-foreground"
|
|
|
|
|
|
}`}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t.label}
|
|
|
|
|
|
{t.count > 0 && (
|
|
|
|
|
|
<Badge variant="secondary" className="ml-1.5 text-xs px-1.5 py-0">
|
|
|
|
|
|
{t.count}
|
|
|
|
|
|
</Badge>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Add player input */}
|
|
|
|
|
|
<div className="flex flex-col sm:flex-row gap-2">
|
|
|
|
|
|
<div className="flex-1">
|
|
|
|
|
|
<Input
|
|
|
|
|
|
placeholder="Player name"
|
|
|
|
|
|
value={playerName}
|
|
|
|
|
|
onChange={(e) => setPlayerName(e.target.value)}
|
|
|
|
|
|
aria-invalid={!!nameError}
|
|
|
|
|
|
maxLength={16}
|
|
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
|
if (e.key === "Enter") {
|
|
|
|
|
|
if (tab === "ops") handleAction("op");
|
|
|
|
|
|
else if (tab === "whitelist") handleAction("whitelist add");
|
|
|
|
|
|
else if (tab === "banned") handleAction("ban");
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
|
|
|
className="w-full"
|
|
|
|
|
|
/>
|
|
|
|
|
|
{nameError && (
|
|
|
|
|
|
<p className="text-xs text-red-300 mt-1">{nameError}</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{tab === "banned" && (
|
|
|
|
|
|
<Input
|
|
|
|
|
|
placeholder="Reason (optional)"
|
|
|
|
|
|
value={banReason}
|
|
|
|
|
|
onChange={(e) => setBanReason(e.target.value)}
|
|
|
|
|
|
className="flex-1"
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<Button
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
if (tab === "ops") handleAction("op");
|
|
|
|
|
|
else if (tab === "whitelist") handleAction("whitelist add");
|
|
|
|
|
|
else if (tab === "banned") handleAction("ban");
|
|
|
|
|
|
}}
|
|
|
|
|
|
disabled={!nameValid || action.isPending}
|
|
|
|
|
|
className="w-full sm:w-auto"
|
|
|
|
|
|
>
|
|
|
|
|
|
{tab === "ops" ? "Add OP" : tab === "whitelist" ? "Add" : "Ban"}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<Separator />
|
|
|
|
|
|
|
|
|
|
|
|
{/* Player lists */}
|
|
|
|
|
|
{tab === "ops" && (
|
|
|
|
|
|
<ul className="space-y-1">
|
|
|
|
|
|
{data.ops.length === 0 && (
|
|
|
|
|
|
<li className="text-sm text-muted-foreground py-2 text-center">No operators</li>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{data.ops.map((p) => (
|
|
|
|
|
|
<li
|
|
|
|
|
|
key={p.uuid || p.name}
|
|
|
|
|
|
className="flex items-center justify-between gap-2 px-3 py-2 rounded-md bg-muted/50 group"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div className="flex items-center gap-2 min-w-0">
|
2026-04-13 00:51:35 -06:00
|
|
|
|
<PlayerAvatar name={p.name} size={24} />
|
2026-04-13 00:46:58 -06:00
|
|
|
|
<span className="text-sm font-medium truncate">{p.name}</span>
|
|
|
|
|
|
<Badge variant="secondary" className="text-xs px-1.5 py-0 shrink-0">
|
|
|
|
|
|
Lv{p.level}
|
|
|
|
|
|
</Badge>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
variant="ghost"
|
|
|
|
|
|
onClick={() => handleAction("deop", p.name)}
|
|
|
|
|
|
disabled={action.isPending}
|
|
|
|
|
|
className="text-xs h-9 shrink-0 text-muted-foreground sm:opacity-0 sm:group-hover:opacity-100 transition"
|
|
|
|
|
|
>
|
|
|
|
|
|
Deop
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{tab === "whitelist" && (
|
|
|
|
|
|
<ul className="space-y-1">
|
|
|
|
|
|
{data.whitelist.length === 0 && (
|
|
|
|
|
|
<li className="text-sm text-muted-foreground py-2 text-center">Whitelist is empty</li>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{data.whitelist.map((p) => (
|
|
|
|
|
|
<li
|
|
|
|
|
|
key={p.uuid || p.name}
|
|
|
|
|
|
className="flex items-center justify-between gap-2 px-3 py-2 rounded-md bg-muted/50 group"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div className="flex items-center gap-2 min-w-0">
|
2026-04-13 00:51:35 -06:00
|
|
|
|
<PlayerAvatar name={p.name} size={24} />
|
2026-04-13 00:46:58 -06:00
|
|
|
|
<span className="text-sm font-medium truncate">{p.name}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
variant="ghost"
|
|
|
|
|
|
onClick={() => handleAction("whitelist remove", p.name)}
|
|
|
|
|
|
disabled={action.isPending}
|
|
|
|
|
|
className="text-xs h-9 text-muted-foreground sm:opacity-0 sm:group-hover:opacity-100 transition"
|
|
|
|
|
|
>
|
|
|
|
|
|
Remove
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{tab === "banned" && (
|
|
|
|
|
|
<ul className="space-y-1">
|
|
|
|
|
|
{data.banned.length === 0 && (
|
|
|
|
|
|
<li className="text-sm text-muted-foreground py-2 text-center">No banned players</li>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{data.banned.map((p) => (
|
|
|
|
|
|
<li
|
|
|
|
|
|
key={p.uuid || p.name}
|
|
|
|
|
|
className="flex items-center justify-between gap-2 px-3 py-2 rounded-md bg-muted/50 group"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div className="min-w-0">
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2026-04-13 00:51:35 -06:00
|
|
|
|
<PlayerAvatar name={p.name} size={24} />
|
2026-04-13 00:46:58 -06:00
|
|
|
|
<span className="text-sm font-medium truncate">{p.name}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{p.reason && (
|
|
|
|
|
|
<p className="text-xs text-muted-foreground truncate ml-8">{p.reason}</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
variant="ghost"
|
|
|
|
|
|
onClick={() => handleAction("pardon", p.name)}
|
|
|
|
|
|
disabled={action.isPending}
|
|
|
|
|
|
className="text-xs h-9 text-muted-foreground sm:opacity-0 sm:group-hover:opacity-100 transition"
|
|
|
|
|
|
>
|
|
|
|
|
|
Unban
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</CardContent>
|
|
|
|
|
|
</Card>
|
Per-player playtime tracking + sparkline hover tooltips
- New GET /api/players/playtime (authed): reads each vanilla stats file
under /home/minecraft/server/world/stats and maps uuid→name via
usercache.json. Returns playtime in ticks and hours, plus file mtime
as "last seen". Memoized 60s via lib/cache#memoAsync.
- New PlaytimeLeaderboard card in the Players tab:
- Rank, avatar (click → PlayerDrawer), relative last-seen, hours.
- Top 10 by default with toggle to show all; combined hours badge.
- PlayerDrawer surfaces the player's total hours + last-seen using the
same cached playtime query, plus fills in UUID if the player is not
in ops/whitelist/banned.
- lib/time.ts: formatHours() — minutes under 1h, "H.Hh" under a day,
"Dd Hh" above.
- Analytics sparklines gain hover/touch tooltips:
- Timestamps threaded through from each MetricEntry.
- SVG overlay captures onMouseMove/onTouchMove, computes nearest
index by x, draws a dashed guide line + focus dot.
- Floating tooltip shows HH:MM + formatted value with unit; edge
clamping keeps it in-frame at the extremes.
- Per-chart formatValue so RAM shows GB, CPU 0 decimals, Players
integer, TPS 1 decimal. Keeps the peak-player marker intact.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 06:24:13 -06:00
|
|
|
|
</div>
|
2026-04-13 00:46:58 -06:00
|
|
|
|
);
|
|
|
|
|
|
}
|