From 0a8fac69d64d6277e66af0f9e42d8450c0ba445a Mon Sep 17 00:00:00 2001
From: Taken
Date: Wed, 20 Aug 2025 00:23:47 +0200
Subject: [PATCH] Fixed things and added tokens finally
---
.../player/[ign]/_components/Sidebar.tsx | 12 ++--
.../player/[ign]/_components/SocialIcons.tsx | 8 ++-
.../_stats/bedwars/bedwars-components.tsx | 67 +++++++++++++++++--
.../player/[ign]/_stats/bedwars/bedwars.tsx | 10 ++-
src/lib/hypixel/guild.ts | 1 -
src/lib/hypixel/stats.ts | 9 ++-
src/lib/schema/player.ts | 9 +--
7 files changed, 91 insertions(+), 25 deletions(-)
diff --git a/src/app/(stats)/player/[ign]/_components/Sidebar.tsx b/src/app/(stats)/player/[ign]/_components/Sidebar.tsx
index ea5f079..dffc4d3 100644
--- a/src/app/(stats)/player/[ign]/_components/Sidebar.tsx
+++ b/src/app/(stats)/player/[ign]/_components/Sidebar.tsx
@@ -65,7 +65,7 @@ export default function Sidebar({ level, ign, player, guild }: SidebarProps) {
{"Challenges Completed: "}
- {formatNumber(getTotalChallenges(player.challenges.all_time))}
+ {formatNumber(getTotalChallenges(player.challenges))}
@@ -155,11 +155,11 @@ export default function Sidebar({ level, ign, player, guild }: SidebarProps) {
Social Links
diff --git a/src/app/(stats)/player/[ign]/_components/SocialIcons.tsx b/src/app/(stats)/player/[ign]/_components/SocialIcons.tsx
index b959809..af63da1 100644
--- a/src/app/(stats)/player/[ign]/_components/SocialIcons.tsx
+++ b/src/app/(stats)/player/[ign]/_components/SocialIcons.tsx
@@ -9,7 +9,13 @@ import { FiTwitter } from "react-icons/fi"
import { toast } from "sonner"
export default function SocialIcons(
- { discord, twitch, youtube, twitter, hypixel }: { discord?: string, twitch?: string, youtube?: string, twitter?: string, hypixel?: string }
+ { discord, twitch, youtube, twitter, hypixel }: {
+ discord?: string
+ twitch?: string
+ youtube?: string
+ twitter?: string
+ hypixel?: string
+ }
) {
return (
<>
diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-components.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-components.tsx
index 54504e2..c5c7464 100644
--- a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-components.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-components.tsx
@@ -1,6 +1,7 @@
-import { getBedwarsStar, getTextColor } from "@/lib/hypixel/bedwars"
+import { getBedwarsStar, getPrestigeName, getTextColor } from "@/lib/hypixel/bedwars"
import { getBWLevelForExp } from "@/lib/hypixel/bedwarsLevel"
import { bedwarsLevelColors } from "@/lib/hypixelFormatters"
+import { cn } from "@/lib/utils"
import Multicolored from "../../_components/Multicolored"
export function BedwarsLevel({ xp }: { xp: number }) {
@@ -15,10 +16,68 @@ export function BedwarsLevel({ xp }: { xp: number }) {
export function BedwarsProgress({ level, percent }: { level: number, percent: number }) {
return (
-
{level}
-
+
+
-
{level + 1}
+
)
}
+
+export function BedWarsPrestige({ level }: { level: number }) {
+ if (level >= 1000 && level < 2000) {
+ return (
+
+ {`${getPrestigeName(level)} ${getBedwarsStar(level)}`}
+
+ )
+ }
+
+ return (
+
+ {`${getPrestigeName(level)} ${getBedwarsStar(level)}`}
+
+ )
+}
+
+function LevelNumber({ level, className }: { level: number, className?: string }) {
+ if (level >= 1000 && level < 2000) {
+ return (
+
+ {level}
+
+ )
+ }
+
+ return {level}
+}
+
+function Progress({ level, percent }: { level: number, percent: number }) {
+ if (level >= 1000 && level < 2000) {
+ return (
+
+
+ )
+ }
+
+ return
+}
diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx
index 4f87713..2bfde8c 100644
--- a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx
@@ -2,7 +2,7 @@
import { Card, CardContent } from "@/components/ui/card"
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
-import { getBedwarsStar, getPrestigeName, getTextColor } from "@/lib/hypixel/bedwars"
+import { formatNumber } from "@/lib/formatters"
import { getBWLevelForExp, getTotalExpForLevel } from "@/lib/hypixel/bedwarsLevel"
import { getProgress } from "@/lib/hypixel/general"
import { Player } from "@/lib/schema/player"
@@ -10,7 +10,7 @@ import { Separator } from "@radix-ui/react-separator"
import { ChevronDown, ChevronUp, Menu } from "lucide-react"
import { useEffect, useRef, useState } from "react"
import CollapsedStats from "../../_components/CollapsedStats"
-import { BedwarsLevel, BedwarsProgress } from "./bedwars-components"
+import { BedwarsLevel, BedWarsPrestige, BedwarsProgress } from "./bedwars-components"
export default function BedwarsStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const ref = useRef(null)
@@ -105,13 +105,11 @@ export default function BedwarsStats({ stats }: { stats: Player["player"]["stats
{"Prestige: "}
-
- {`${getPrestigeName(level)} ${getBedwarsStar(level)}`}
-
+
{"Tokens: "}
- {}
+ {formatNumber(stats.coins)}
diff --git a/src/lib/hypixel/guild.ts b/src/lib/hypixel/guild.ts
index 8a64fb6..c47dfaa 100644
--- a/src/lib/hypixel/guild.ts
+++ b/src/lib/hypixel/guild.ts
@@ -1,4 +1,3 @@
-import { object } from "zod"
import { Guild } from "../schema/guild"
export function getGuildMember(guild: Guild["guild"], uuid: string) {
diff --git a/src/lib/hypixel/stats.ts b/src/lib/hypixel/stats.ts
index 3f56577..b1967d5 100644
--- a/src/lib/hypixel/stats.ts
+++ b/src/lib/hypixel/stats.ts
@@ -20,11 +20,15 @@ export function getTotalCoins(stats: Record total + (quest.completions?.length || 0), 0)
}
-export function getTotalChallenges(challenges: Player["player"]["challenges"]["all_time"]) {
- return Object.values(challenges).reduce((total, challenge) => total + challenge, 0)
+export function getTotalChallenges(challenges: Player["player"]["challenges"]) {
+ if (!challenges?.all_time) return 0
+
+ return Object.values(challenges.all_time).reduce((total, challenge) => total + challenge, 0)
}
export function rewardClaimed(claimedAt?: number) {
@@ -39,4 +43,3 @@ export function rewardClaimed(claimedAt?: number) {
return false
}
}
-
diff --git a/src/lib/schema/player.ts b/src/lib/schema/player.ts
index 0c6a9a5..5a26fb4 100644
--- a/src/lib/schema/player.ts
+++ b/src/lib/schema/player.ts
@@ -2,8 +2,8 @@ import z from "zod"
export const playerSchema = z.looseObject({
player: z.looseObject({
- displayname: z.string().optional(),
- uuid: z.string().optional(),
+ displayname: z.string(),
+ uuid: z.string(),
newPackageRank: z.string().optional(),
monthlyPackageRank: z.string().optional(),
rankPlusColor: z.string().optional(),
@@ -14,6 +14,7 @@ export const playerSchema = z.looseObject({
stats: z.looseObject({
Bedwars: z.looseObject({
Experience: z.number().default(0),
+ coins: z.number().default(0),
winstreak: z.number().optional(),
kills_bedwars: z.number().default(0),
deaths_bedwars: z.number().default(0),
@@ -31,9 +32,9 @@ export const playerSchema = z.looseObject({
completions: z.array(
z.looseObject({
time: z.number()
- }).optional()
+ })
).optional()
- }).optional()
+ })
).optional(),
challenges: z.looseObject({
all_time: z.record(z.string(), z.number())