diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx
index d18c769..b0c09b1 100644
--- a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx
@@ -2,10 +2,10 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@
import { formatNumber } from "@/lib/formatters"
import { concatStatArrays } from "@/lib/funcs"
import { _BedwarsStats, getBedwarsModeStats, getBestMode } from "@/lib/hypixel/bedwars"
-import { Player } from "@/lib/schema/player"
+import { NonNullStats } from "@/lib/schema/player"
import { cn } from "@/lib/utils"
-export default function BedwarsStatTable({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+export default function BedwarsStatTable({ stats }: { stats: NonNullStats["Bedwars"] }) {
return (
@@ -69,7 +69,7 @@ function BedwarsTableHeader() {
)
}
-function SoloStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function SoloStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("solo", stats as _BedwarsStats)
const isBest = getBestMode(stats as _BedwarsStats) === "solo"
@@ -83,7 +83,7 @@ function SoloStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
)
}
-function DoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function DoublesStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("doubles", stats as _BedwarsStats)
const isBest = getBestMode(stats as _BedwarsStats) === "doubles"
@@ -97,7 +97,7 @@ function DoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }
)
}
-function ThreesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function ThreesStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("3s", stats as _BedwarsStats)
const isBest = getBestMode(stats as _BedwarsStats) === "3s"
@@ -111,7 +111,7 @@ function ThreesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] })
)
}
-function FoursStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function FoursStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("4s", stats as _BedwarsStats)
const isBest = getBestMode(stats as _BedwarsStats) === "4s"
@@ -125,7 +125,7 @@ function FoursStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] })
)
}
-function CoreModeStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function CoreModeStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const soloStats = getBedwarsModeStats("solo", stats as _BedwarsStats, true)
const doublesStats = getBedwarsModeStats("doubles", stats as _BedwarsStats, true)
const threesStats = getBedwarsModeStats("3s", stats as _BedwarsStats, true)
@@ -143,7 +143,7 @@ function CoreModeStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"]
)
}
-function FourVFourStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function FourVFourStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("4v4", stats as _BedwarsStats)
return (
@@ -156,7 +156,7 @@ function FourVFourStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"]
)
}
-function RushDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function RushDoublesStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("rush_2s", stats as _BedwarsStats)
return (
@@ -169,7 +169,7 @@ function RushDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars
)
}
-function Rush4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function Rush4sStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("rush_4s", stats as _BedwarsStats)
return (
@@ -182,7 +182,7 @@ function Rush4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] })
)
}
-function UltimateDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function UltimateDoublesStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("ultimate_2s", stats as _BedwarsStats)
return (
@@ -195,7 +195,7 @@ function UltimateDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bed
)
}
-function Ultimate4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function Ultimate4sStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("ultimate_4s", stats as _BedwarsStats)
return (
@@ -208,7 +208,7 @@ function Ultimate4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"
)
}
-function LuckyDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function LuckyDoublesStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("lucky_2s", stats as _BedwarsStats)
return (
@@ -221,7 +221,7 @@ function LuckyDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwar
)
}
-function Lucky4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function Lucky4sStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("lucky_4s", stats as _BedwarsStats)
return (
@@ -234,7 +234,7 @@ function Lucky4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }
)
}
-function VoidlessDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function VoidlessDoublesStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("voidless_2s", stats as _BedwarsStats)
return (
@@ -247,7 +247,7 @@ function VoidlessDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bed
)
}
-function Voidless4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function Voidless4sStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("voidless_4s", stats as _BedwarsStats)
return (
@@ -260,7 +260,7 @@ function Voidless4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"
)
}
-function ArmedDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function ArmedDoublesStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("armed_2s", stats as _BedwarsStats)
return (
@@ -273,7 +273,7 @@ function ArmedDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwar
)
}
-function Armed4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function Armed4sStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("armed_4s", stats as _BedwarsStats)
return (
@@ -286,7 +286,7 @@ function Armed4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }
)
}
-function Swap4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function Swap4sStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("swap_4s", stats as _BedwarsStats)
return (
@@ -299,7 +299,7 @@ function Swap4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] })
)
}
-function Underworld4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function Underworld4sStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("underworld_4s", stats as _BedwarsStats)
return (
@@ -312,7 +312,7 @@ function Underworld4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwar
)
}
-function CastleStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function CastleStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const modeStats = getBedwarsModeStats("castle", stats as _BedwarsStats)
return (
@@ -325,7 +325,7 @@ function CastleStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] })
)
}
-function AllModeStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+function AllModeStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const soloStats = getBedwarsModeStats("solo", stats as _BedwarsStats, true)
const doublesStats = getBedwarsModeStats("doubles", stats as _BedwarsStats, true)
const threesStats = getBedwarsModeStats("3s", stats as _BedwarsStats, true)
diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx
index bcf3ae1..7317438 100644
--- a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx
@@ -5,7 +5,7 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/component
import { Separator } from "@/components/ui/separator"
import { getBWLevelForExp, getTotalExpForLevel } from "@/lib/hypixel/bedwarsLevel"
import { getProgress } from "@/lib/hypixel/general"
-import { Player } from "@/lib/schema/player"
+import { NonNullStats } from "@/lib/schema/player"
import { ChevronDown, ChevronUp } from "lucide-react"
import { useEffect, useRef, useState } from "react"
import CollapsedStats from "../../_components/CollapsedStats"
@@ -13,7 +13,7 @@ import { BedwarsLevel, BedwarsProgress } from "./bedwars-components"
import BedwarsStatTable from "./bedwars-table"
import BedwarsGeneralStats from "./stats"
-export default function BedwarsStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
+export default function BedwarsStats({ stats }: { stats: NonNullStats["Bedwars"] }) {
const ref = useRef(null)
const [opened, setOpened] = useState(false)
diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx
index 3c3ae9e..397ab57 100644
--- a/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx
@@ -1,12 +1,12 @@
import { formatNumber } from "@/lib/formatters"
import { getLatestRoom, getWalletMax } from "@/lib/hypixel/bedwars"
-import { Player } from "@/lib/schema/player"
+import { NonNullStats } from "@/lib/schema/player"
import { BasicStat, Stat } from "../../_components/Stats"
import { BedWarsPrestige } from "./bedwars-components"
export default function BedwarsGeneralStats(
{ statsChecked, level, percent, kd, fkd, bbl, wl }: {
- statsChecked: Player["player"]["stats"]["Bedwars"]
+ statsChecked: NonNullStats["Bedwars"]
level: number
percent: number
kd: string
diff --git a/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx b/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx
index 2d1542b..5ad9136 100644
--- a/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx
@@ -6,14 +6,14 @@ import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { getProgress } from "@/lib/hypixel/general"
import { getSkywarsLevel, getSkywarsXpForLevel } from "@/lib/hypixel/skyWarsLevel"
-import { Player } from "@/lib/schema/player"
+import { NonNullStats } from "@/lib/schema/player"
import { ChevronDown, ChevronUp } from "lucide-react"
import { useEffect, useRef, useState } from "react"
import CollapsedStats from "../../_components/CollapsedStats"
import { SkywarsLevel, SkywarsProgress } from "./skywars-components"
import SkyWarsGeneralStats from "./stats"
-export default function SkyWarsStats({ stats }: { stats: Player["player"]["stats"]["SkyWars"] }) {
+export default function SkyWarsStats({ stats }: { stats: NonNullStats["SkyWars"] }) {
const ref = useRef(null)
const [opened, setOpened] = useState(false)
diff --git a/src/app/(stats)/player/[ign]/_stats/skywars/stats.tsx b/src/app/(stats)/player/[ign]/_stats/skywars/stats.tsx
index 8559234..bc1eb08 100644
--- a/src/app/(stats)/player/[ign]/_stats/skywars/stats.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/skywars/stats.tsx
@@ -1,5 +1,5 @@
import { formatNumber } from "@/lib/formatters"
-import { Player } from "@/lib/schema/player"
+import { NonNullStats } from "@/lib/schema/player"
import { BasicStat, Stat } from "../../_components/Stats"
import { SkywarsPrestige } from "./skywars-components"
@@ -7,7 +7,7 @@ export default function SkyWarsGeneralStats({
statsChecked,
level
}: {
- statsChecked: Player["player"]["stats"]["SkyWars"]
+ statsChecked: NonNullStats["SkyWars"]
level: number
}) {
const stats = statsChecked!
diff --git a/src/app/(stats)/player/[ign]/page.tsx b/src/app/(stats)/player/[ign]/page.tsx
index 7bab0ff..4015aa2 100644
--- a/src/app/(stats)/player/[ign]/page.tsx
+++ b/src/app/(stats)/player/[ign]/page.tsx
@@ -1,4 +1,5 @@
import DisplayName from "@/components/player/displayname"
+import { Card, CardContent } from "@/components/ui/card"
import { getGuild } from "@/lib/hypixel/api/guild"
import { getUuid } from "@/lib/hypixel/api/mojang"
import { getPlayer } from "@/lib/hypixel/api/player"
@@ -65,6 +66,7 @@ async function SuspendedPage({ ign: pign }: { ign: string }) {
plusColor={player.rankPlusColor}
guildTag={guild?.tag}
tagColor={guild?.tagColor}
+ specialRank={player.rank}
/>
@@ -72,10 +74,24 @@ async function SuspendedPage({ ign: pign }: { ign: string }) {
-
-
-
-
+ {player.stats !== undefined ?
+ (
+
+
+
+
+ ) :
+ (
+
+
+
+
+ No stats avaiable. If they are staff then they most likely have their api off.
+
+
+
+
+ )}
)
diff --git a/src/components/player/displayname.tsx b/src/components/player/displayname.tsx
index 7a30595..d2aa938 100644
--- a/src/components/player/displayname.tsx
+++ b/src/components/player/displayname.tsx
@@ -6,7 +6,7 @@ type MonthlyPackageRank = Player["player"]["monthlyPackageRank"]
type RankColor = Player["player"]["monthlyRankColor"]
export default function DisplayName(
- { ign, rank, monthly, rankColor, plusColor, guildTag, tagColor }: {
+ { ign, rank, monthly, rankColor, plusColor, guildTag, tagColor, specialRank }: {
ign: string
rank: NewPackageRank
monthly: MonthlyPackageRank
@@ -14,17 +14,37 @@ export default function DisplayName(
plusColor: string | undefined
guildTag: string | undefined
tagColor: string | undefined
+ specialRank: string | undefined
}
) {
return (
<>
- {" "}
-
+ {" "}
+ {" "}
+
>
)
}
-function PlayerIGN({ ign, rank, monthly, rankColor }: { ign: string, rank: NewPackageRank, monthly: MonthlyPackageRank, rankColor: RankColor }) {
+function PlayerIGN(
+ { ign, rank, monthly, rankColor, specialRank }: {
+ ign: string
+ rank: NewPackageRank
+ monthly: MonthlyPackageRank
+ rankColor: RankColor
+ specialRank: string | undefined
+ }
+) {
+ if (specialRank) {
+ if (specialRank === "YOUTUBER") {
+ return {ign}
+ }
+
+ if (specialRank === "STAFF") {
+ return {ign}
+ }
+ }
+
if (monthly === "SUPERSTAR") {
if (rankColor === "GOLD") {
return {ign}
@@ -48,8 +68,36 @@ function PlayerIGN({ ign, rank, monthly, rankColor }: { ign: string, rank: NewPa
}
function PlayerRank(
- { rank, monthly, plusColor, rankColor }: { rank: NewPackageRank, monthly: MonthlyPackageRank, plusColor?: string, rankColor: RankColor }
+ { rank, monthly, plusColor, rankColor, specialRank }: {
+ rank: NewPackageRank
+ monthly: MonthlyPackageRank
+ plusColor?: string
+ rankColor: RankColor
+ specialRank: string | undefined
+ }
) {
+ if (specialRank) {
+ if (specialRank === "YOUTUBER") {
+ return (
+ <>
+ [
+ YOUTUBE
+ ]
+ >
+ )
+ }
+
+ if (specialRank === "STAFF") {
+ return (
+ <>
+ [
+ ዞ
+ ]
+ >
+ )
+ }
+ }
+
if (monthly === "SUPERSTAR") {
if (rankColor === "GOLD") {
return (
diff --git a/src/lib/hypixel/guild.ts b/src/lib/hypixel/guild.ts
index c47dfaa..30cd55d 100644
--- a/src/lib/hypixel/guild.ts
+++ b/src/lib/hypixel/guild.ts
@@ -6,9 +6,16 @@ export function getGuildMember(guild: Guild["guild"], uuid: string) {
export function getGuildRankTag(guild: Guild["guild"], uuid: string) {
const member = getGuildMember(guild, uuid)
- return member?.rank === "Guild Master"
- ? "[GM]"
- : `[${guild.ranks.find(r => r.name === member?.rank)?.tag}]`
+
+ if (member?.rank === "Guild Master") return "[GM]"
+
+ const rank = guild.ranks.find(r => r.name === member?.rank)?.tag
+
+ if (rank == null) {
+ return ""
+ } else {
+ return `[${rank}]`
+ }
}
export function getMemberGEXP(guild: Guild["guild"], uuid: string, days: number = 0) {
diff --git a/src/lib/hypixel/stats.ts b/src/lib/hypixel/stats.ts
index c517b6e..43d6f34 100644
--- a/src/lib/hypixel/stats.ts
+++ b/src/lib/hypixel/stats.ts
@@ -15,7 +15,11 @@ export function getCoinMultiplier(level: number) {
return MULTIPLIER[0].value
}
-export function getTotalCoins(stats: Record>) {
+export function getTotalCoins(stats: Record> | undefined) {
+ if (!stats) {
+ return 0
+ }
+
return Object.values(stats).reduce((total, stat) => total + (stat.coins || 0), 0)
}
diff --git a/src/lib/schema/player.ts b/src/lib/schema/player.ts
index cf7f52d..ca8649d 100644
--- a/src/lib/schema/player.ts
+++ b/src/lib/schema/player.ts
@@ -15,7 +15,7 @@ export const playerSchema = z.looseObject({
stats: z.looseObject({
Bedwars: bedwarsStatsSchema.optional(),
SkyWars: skywarsStatsSchema.optional()
- }),
+ }).optional(),
quests: z.record(
z.string(),
z.looseObject({
@@ -47,8 +47,10 @@ export const playerSchema = z.looseObject({
TWITTER: z.string().optional(),
YOUTUBE: z.string().optional()
}).optional()
- }).optional()
+ }).optional(),
+ rank: z.string().optional()
})
})
export type Player = z.infer
+export type NonNullStats = NonNullable