Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Fix player statistics not appearing in alltime group requests
Browse files Browse the repository at this point in the history
  • Loading branch information
UCDFiddes committed Jul 4, 2024
1 parent 22ae3b1 commit b6107d4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hive-bedrock-api",
"version": "2.1.0",
"version": "2.1.1",
"description": "An API wrapper for the Hive Minecraft Bedrock Edition server.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
37 changes: 23 additions & 14 deletions src/methods/getAllTimeStatistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,35 @@ export default async function getAllTimeStatistics<G extends Game>(
data: null,
};

let response = await fetchEndpoint(`/game/all/${game_id}/${identifier}`, method_options?.init);
let response = await fetchEndpoint(
`/game/all/${game_id}/${identifier}`,
method_options?.init
);
if (response.error) return response;

if (game_id === "all") {
let response_data = Object.entries(response.data);
let processed_data: Partial<AllGameStatisticsPlayer> = Object.fromEntries(
response_data.map(([id, statistics]) => {
if (!statistics || !isGame(id as Game) || Array.isArray(statistics))
return [id, null];
let processed_data: Partial<AllGameStatisticsPlayer> =
Object.fromEntries(
response_data.map(([id, statistics]) => {
if (id === "main")
return ["player", PlayerProcessor(statistics)];

if (id === "main") return ["player", PlayerProcessor(statistics)];
if (
!statistics ||
!isGame(id as Game) ||
Array.isArray(statistics)
)
return [id, null];

return [
id,
typeof AllTimeProcessors[id as Game] === "function"
? AllTimeProcessors[id as Game](statistics)
: null,
];
})
);
return [
id,
typeof AllTimeProcessors[id as Game] === "function"
? AllTimeProcessors[id as Game](statistics)
: null,
];
})
);

return { ...response, data: processed_data };
}
Expand Down

0 comments on commit b6107d4

Please sign in to comment.