hive-bedrock-api 3.0.0-alpha.2 → 3.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  An API wrapper for the Hive Minecraft Bedrock Edition server. Which allows you to get stats for leaderboards, players, cosmetics, unique player counts, maps and metadata.
4
4
 
5
5
  > [!NOTE]
6
- > This API responses returnded from this package will differ from the responses returned by the offical Hive API. This due to our preference and needs when using this package on [Hive Backpack](https://hivebackpack.com).
6
+ > This API responses returned from this package will differ from the responses returned by the official Hive API. This due to our preference and needs when using this package on [Hive Backpack](https://hivebackpack.com).
7
7
 
8
8
  ## Getting started
9
9
 
@@ -16,7 +16,7 @@ You should also include `hive-bedrock-data` as it includes useful functions and
16
16
 
17
17
  ## Usage
18
18
 
19
- To start using this API wrapper you may construct the main class `HiveAPI`. This class can take in seperate options that will be used in every http request.
19
+ To start using the API, construct the main class `HiveAPI`. This class takes in options that will be used in every HTTP request.
20
20
 
21
21
  ```ts
22
22
  const api = new HiveAPI({
package/lib/index.d.ts CHANGED
@@ -5,9 +5,10 @@ import { ProcessedGlobalStatisticsResponse } from "./processors/global_statistic
5
5
  import { ProcessedMapResponse } from "./processors/map";
6
6
  import { ProcessedGameMetadata } from "./processors/meta";
7
7
  import { ProcessedPlayerSearchResponse } from "./processors/player_search";
8
- import { ProcessedAllGamesResponse, ProcessedGame } from "./processors/game";
8
+ import { AvailableLeaderboardResponse, ProcessedAllGamesResponse, ProcessedGame, ProcessedMonthlyGamesResponse } from "./processors/game";
9
9
  interface Options {
10
10
  resolveDynamicTitles?: boolean;
11
+ useModernLeaderboardSource?: boolean;
11
12
  apiBaseEndpoint?: string;
12
13
  requestInit?: RequestInit;
13
14
  }
@@ -41,14 +42,15 @@ export default class HiveAPI {
41
42
  getStatistics(identifier: string, timeframe: Timeframe.Monthly, options?: {
42
43
  month?: number;
43
44
  year?: number;
44
- }): Promise<MethodResponse<ProcessedAllGamesResponse>>;
45
+ }): Promise<MethodResponse<ProcessedMonthlyGamesResponse>>;
45
46
  getStatistics<G extends Game>(identifier: string, timeframe: Timeframe.Monthly, options: {
46
47
  game: G;
47
48
  month?: number;
48
49
  year?: number;
49
- }): Promise<MethodResponse<ProcessedGame<Timeframe.AllTime, false>[G]>>;
50
+ }): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, false>[G]>>;
50
51
  private _getStatisticsAllTime;
51
52
  private _getStatisticsMonthly;
53
+ getAvailableMonthlyLeaderboards<G extends Game>(game: G): Promise<MethodResponse<AvailableLeaderboardResponse>>;
52
54
  /**
53
55
  * `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
54
56
  * @param identifier Username or UUID of the player
@@ -65,6 +67,10 @@ export default class HiveAPI {
65
67
  */
66
68
  getLeaderboard<G extends Game>(timeframe: Timeframe.AllTime, game: G): Promise<MethodResponse<ProcessedGame<Timeframe.AllTime, true>[G][] | null>>;
67
69
  getLeaderboard<G extends Game>(timeframe: Timeframe.Monthly, game: G): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][] | null>>;
70
+ getLeaderboard<G extends Game>(timeframe: Timeframe.Monthly, game: G, options: {
71
+ month?: number;
72
+ year?: number;
73
+ }): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][] | null>>;
68
74
  private _getLeaderboardAllTime;
69
75
  private _getLeaderboardMonthly;
70
76
  /**
package/lib/index.js CHANGED
@@ -72,8 +72,11 @@ var player_search_1 = __importDefault(require("./processors/player_search"));
72
72
  var game_1 = __importDefault(require("./processors/game"));
73
73
  var HiveAPI = /** @class */ (function () {
74
74
  function HiveAPI(options) {
75
- if (options === void 0) { options = { resolveDynamicTitles: true, apiBaseEndpoint: hive_bedrock_data_1.API_BASE_ENDPOINT }; }
75
+ if (options === void 0) { options = {}; }
76
+ var _a;
76
77
  this.options = options;
78
+ this.options = options;
79
+ this.options.apiBaseEndpoint = (_a = this.options.apiBaseEndpoint) !== null && _a !== void 0 ? _a : hive_bedrock_data_1.API_BASE_ENDPOINT;
77
80
  }
78
81
  HiveAPI.prototype._fetchAPI = function (endpoint) {
79
82
  return __awaiter(this, void 0, void 0, function () {
@@ -87,7 +90,7 @@ var HiveAPI = /** @class */ (function () {
87
90
  case 1:
88
91
  _c.trys.push([1, 4, , 5]);
89
92
  start = performance.now();
90
- return [4 /*yield*/, fetch(url, __assign(__assign({}, this.options.requestInit), { headers: __assign({ "X-Hive-Resolve-Stat-Track": ((_a = this.options.resolveDynamicTitles) !== null && _a !== void 0 ? _a : true).toString() }, (_b = this.options.requestInit) === null || _b === void 0 ? void 0 : _b.headers) }))];
93
+ return [4 /*yield*/, fetch(url, __assign(__assign({}, this.options.requestInit), { headers: __assign({ "X-Hive-Resolve-Stat-Track": ((_a = this.options.resolveDynamicTitles) !== null && _a !== void 0 ? _a : true).toString(), "X-Hive-Leaderboard-Source": this.options.useModernLeaderboardSource ? "modern" : "legacy" }, (_b = this.options.requestInit) === null || _b === void 0 ? void 0 : _b.headers) }))];
91
94
  case 2:
92
95
  request = _c.sent();
93
96
  if (!request.ok)
@@ -232,6 +235,21 @@ var HiveAPI = /** @class */ (function () {
232
235
  });
233
236
  });
234
237
  };
238
+ HiveAPI.prototype.getAvailableMonthlyLeaderboards = function (game) {
239
+ return __awaiter(this, void 0, void 0, function () {
240
+ var _a, response, error, meta;
241
+ return __generator(this, function (_b) {
242
+ switch (_b.label) {
243
+ case 0: return [4 /*yield*/, this._fetchAPI("/game/monthly/".concat(game, "/available"))];
244
+ case 1:
245
+ _a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
246
+ if (error)
247
+ return [2 /*return*/, { data: null, error: error, meta: meta }];
248
+ return [2 /*return*/, { data: response, error: null, meta: meta }];
249
+ }
250
+ });
251
+ });
252
+ };
235
253
  /**
236
254
  * `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
237
255
  * @param identifier Username or UUID of the player
@@ -1,19 +1,19 @@
1
1
  import { Game, Statistics, Timeframe } from "hive-bedrock-data";
2
2
  import { OmittedSpecialStatistics } from "../types/types";
3
- export interface Processed_JustBuild_AllTimeStatistics extends OmittedSpecialStatistics<Game.JustBuild, Timeframe.AllTime> {
4
- id: Game.JustBuild;
3
+ export interface Processed_BuildBattle_AllTimeStatistics extends OmittedSpecialStatistics<Game.BuildBattle, Timeframe.AllTime> {
4
+ id: Game.BuildBattle;
5
5
  level: number;
6
6
  losses: number;
7
7
  win_percentage: number;
8
8
  total_ratings: number;
9
9
  first_played: number | null;
10
10
  }
11
- export interface Processed_JustBuild_MonthlyStatistics extends Statistics<Game.JustBuild, Timeframe.Monthly> {
12
- id: Game.JustBuild;
11
+ export interface Processed_BuildBattle_MonthlyStatistics extends Statistics<Game.BuildBattle, Timeframe.Monthly> {
12
+ id: Game.BuildBattle;
13
13
  level: number;
14
14
  total_ratings: number;
15
15
  losses: number;
16
16
  win_percentage: number;
17
17
  }
18
- export declare function processAllTime_BUILD(statistics: Partial<Statistics<Game.JustBuild, Timeframe.AllTime>>): Processed_JustBuild_AllTimeStatistics | null;
19
- export declare function processMonthly_BUILD(statistics: Partial<Statistics<Game.JustBuild, Timeframe.Monthly>>): Processed_JustBuild_MonthlyStatistics | null;
18
+ export declare function processAllTime_BUILD(statistics: Partial<Statistics<Game.BuildBattle, Timeframe.AllTime>>): Processed_BuildBattle_AllTimeStatistics | null;
19
+ export declare function processMonthly_BUILD(statistics: Partial<Statistics<Game.BuildBattle, Timeframe.Monthly>>): Processed_BuildBattle_MonthlyStatistics | null;
@@ -24,12 +24,12 @@ function processAllTime_BUILD(statistics) {
24
24
  var _a;
25
25
  if (!statistics || Array.isArray(statistics))
26
26
  return null;
27
- return __assign(__assign(__assign(__assign({ UUID: statistics.UUID }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.JustBuild, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processBuildRatings_1.default)(statistics.rating_love_received, statistics.rating_great_received, statistics.rating_good_received, statistics.rating_okay_received, statistics.rating_meh_received)), { first_played: (_a = statistics.first_played) !== null && _a !== void 0 ? _a : null });
27
+ return __assign(__assign(__assign(__assign({ UUID: statistics.UUID }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.BuildBattle, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processBuildRatings_1.default)(statistics.rating_love_received, statistics.rating_great_received, statistics.rating_good_received, statistics.rating_okay_received, statistics.rating_meh_received)), { first_played: (_a = statistics.first_played) !== null && _a !== void 0 ? _a : null });
28
28
  }
29
29
  function processMonthly_BUILD(statistics) {
30
30
  var _a, _b;
31
31
  if (!statistics || Array.isArray(statistics))
32
32
  return null;
33
33
  var index = (_a = statistics.index) !== null && _a !== void 0 ? _a : 0;
34
- return __assign(__assign(__assign({ index: (_b = statistics.index) !== null && _b !== void 0 ? _b : 0, human_index: index + 1, username: statistics.username }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.JustBuild, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processBuildRatings_1.default)(statistics.rating_love_received, statistics.rating_great_received, statistics.rating_good_received, statistics.rating_okay_received, statistics.rating_meh_received));
34
+ return __assign(__assign(__assign({ index: (_b = statistics.index) !== null && _b !== void 0 ? _b : 0, human_index: index + 1, username: statistics.username }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.BuildBattle, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processBuildRatings_1.default)(statistics.rating_love_received, statistics.rating_great_received, statistics.rating_good_received, statistics.rating_okay_received, statistics.rating_meh_received));
35
35
  }
@@ -88,7 +88,7 @@ export interface ProcessedGameGROUND {
88
88
  projectiles_fired: number;
89
89
  }
90
90
  export interface ProcessedGameBUILD {
91
- id: Game.JustBuild;
91
+ id: Game.BuildBattle;
92
92
  xp: number;
93
93
  played: number;
94
94
  victories: number;
@@ -128,7 +128,7 @@ export interface ProcessedGameMURDER {
128
128
  prestige: number;
129
129
  }
130
130
  export interface ProcessedGameSKY {
131
- id: Game.Skywars;
131
+ id: Game.SkyWars;
132
132
  xp: number;
133
133
  played: number;
134
134
  victories: number;
@@ -140,9 +140,10 @@ export interface ProcessedGameSKY {
140
140
  mystery_chests_destroyed: number;
141
141
  ores_mined: number;
142
142
  spells_used: number;
143
+ prestige: number;
143
144
  }
144
145
  export interface ProcessedGameSKYKITS {
145
- id: Game.SkywarsKits;
146
+ id: Game.SkyWarsKits;
146
147
  xp: number;
147
148
  played: number;
148
149
  victories: number;
@@ -157,7 +158,7 @@ export interface ProcessedGameSKYKITS {
157
158
  selected_kit: string;
158
159
  }
159
160
  export interface ProcessedGameSKYCLASSIC {
160
- id: Game.SkywarsClassic;
161
+ id: Game.SkyWarsClassic;
161
162
  xp: number;
162
163
  played: number;
163
164
  victories: number;
@@ -241,7 +242,10 @@ export type AdditionalStatistics<T extends Timeframe, L extends boolean> = (T ex
241
242
  level: number;
242
243
  } & (L extends true ? {} : {
243
244
  first_played: number;
244
- }) : {}) & (L extends true ? {
245
+ }) : {
246
+ position: number;
247
+ username: string;
248
+ }) & (L extends true ? {
245
249
  position: number;
246
250
  username: string;
247
251
  UUID: string;
@@ -254,17 +258,19 @@ export interface ProcessedGame<T extends Timeframe, L extends boolean> {
254
258
  [Game.DeathRun]: ProcessedGameDR & AdditionalStatistics<T, L>;
255
259
  [Game.Gravity]: ProcessedGameGRAV & AdditionalStatistics<T, L>;
256
260
  [Game.GroundWars]: ProcessedGameGROUND & AdditionalStatistics<T, L>;
257
- [Game.JustBuild]: ProcessedGameBUILD & AdditionalStatistics<T, L>;
261
+ [Game.BuildBattle]: ProcessedGameBUILD & AdditionalStatistics<T, L>;
258
262
  [Game.HideAndSeek]: ProcessedGameHIDE & AdditionalStatistics<T, L>;
259
263
  [Game.MurderMystery]: ProcessedGameMURDER & AdditionalStatistics<T, L>;
264
+ [Game.SkyWars]: ProcessedGameSKY & AdditionalStatistics<T, L>;
265
+ [Game.SkyWarsClassic]: ProcessedGameSKYCLASSIC & AdditionalStatistics<T, L>;
266
+ [Game.SkyWarsKits]: ProcessedGameSKYKITS & AdditionalStatistics<T, L>;
260
267
  [Game.SurvivalGames]: ProcessedGameSG & AdditionalStatistics<T, L>;
261
268
  [Game.TheBridge]: ProcessedGameBRIDGE & AdditionalStatistics<T, L>;
262
269
  [Game.TreasureWars]: ProcessedGameWARS & AdditionalStatistics<T, L>;
263
- [Game.ParkourWorlds]: ProcessedGamePARKOUR;
270
+ [Game.ParkourWorlds]: L extends true ? never : T extends Timeframe.Monthly ? never : ProcessedGamePARKOUR;
264
271
  }
265
272
  export default function processGame<G extends Game, T extends Timeframe, L extends boolean>(game: G, timeframe: T, isLeaderboard: L, response: any): ProcessedGame<T, L>[G] | null;
266
273
  export declare const processors: {
267
- [x: number]: ((response: any) => ProcessedGameSKY) | ((response: any) => ProcessedGameSKYCLASSIC);
268
274
  bed: (response: any) => ProcessedGameBED;
269
275
  drop: (response: any) => ProcessedGameDROP;
270
276
  party: (response: any) => ProcessedGamePARTY;
@@ -275,10 +281,13 @@ export declare const processors: {
275
281
  build: (response: any) => ProcessedGameBUILD;
276
282
  hide: (response: any) => ProcessedGameHIDE;
277
283
  murder: (response: any) => ProcessedGameMURDER;
284
+ sky: (response: any) => ProcessedGameSKY;
285
+ "sky-kits": (response: any) => ProcessedGameSKYKITS;
286
+ "sky-classic": (response: any) => ProcessedGameSKYCLASSIC;
278
287
  sg: (response: any) => ProcessedGameSG;
279
288
  bridge: (response: any) => ProcessedGameBRIDGE;
280
289
  wars: (response: any) => ProcessedGameWARS;
281
- parkour: (response: any) => ProcessedGamePARKOUR;
290
+ parkour: (response: any) => ProcessedGamePARKOUR | null;
282
291
  };
283
292
  export declare function validateNumber(value: number, def?: number): number;
284
293
  export declare function calculateKDR(kills: number, deaths: number): number;
@@ -297,3 +306,10 @@ export interface ProcessedMonthlyGamesResponse {
297
306
  [G in Game]: ProcessedGame<Timeframe.Monthly, false>[G] | null;
298
307
  };
299
308
  }
309
+ export interface AvailableLeaderboard {
310
+ month: string;
311
+ year: string;
312
+ month_number: number;
313
+ resource: string;
314
+ }
315
+ export type AvailableLeaderboardResponse = AvailableLeaderboard[];
@@ -35,15 +35,17 @@ function processGame(game, timeframe, isLeaderboard, response) {
35
35
  if (Array.isArray(response))
36
36
  return null;
37
37
  var data = exports.processors[game](response);
38
+ if (!data)
39
+ return null;
38
40
  if ("played" in data && data.played === 0)
39
41
  return null;
40
42
  if (timeframe === hive_bedrock_data_1.Timeframe.AllTime && "xp" in data)
41
43
  data.level = (_a = (0, hive_bedrock_data_1.calculateLevelFromXP)(data.xp, game)) !== null && _a !== void 0 ? _a : 1;
42
- if (timeframe === hive_bedrock_data_1.Timeframe.AllTime && "first_played" in data)
44
+ if (timeframe === hive_bedrock_data_1.Timeframe.AllTime && "first_played" in response)
43
45
  data.first_played = response.first_played;
44
- if (isLeaderboard && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
46
+ if ((isLeaderboard || timeframe === hive_bedrock_data_1.Timeframe.Monthly) && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
45
47
  data.position = response.human_index;
46
- if (isLeaderboard && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
48
+ if ((isLeaderboard || timeframe === hive_bedrock_data_1.Timeframe.Monthly) && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
47
49
  data.username = response.username;
48
50
  if (isLeaderboard && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
49
51
  data.UUID = response.UUID;
@@ -158,10 +160,10 @@ exports.processors = (_a = {},
158
160
  projectiles_fired: (_h = response.projectiles_fired) !== null && _h !== void 0 ? _h : 0,
159
161
  });
160
162
  },
161
- _a[hive_bedrock_data_1.Game.JustBuild] = function (response) {
163
+ _a[hive_bedrock_data_1.Game.BuildBattle] = function (response) {
162
164
  var _a, _b, _c, _d, _e, _f, _g, _h;
163
165
  return ({
164
- id: hive_bedrock_data_1.Game.JustBuild,
166
+ id: hive_bedrock_data_1.Game.BuildBattle,
165
167
  xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
166
168
  played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
167
169
  victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
@@ -213,10 +215,10 @@ exports.processors = (_a = {},
213
215
  prestige: (_h = response.prestige) !== null && _h !== void 0 ? _h : 0,
214
216
  });
215
217
  },
216
- _a[hive_bedrock_data_1.Game.Skywars] = function (response) {
217
- var _a, _b, _c, _d, _e, _f, _g, _h;
218
+ _a[hive_bedrock_data_1.Game.SkyWars] = function (response) {
219
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
218
220
  return ({
219
- id: hive_bedrock_data_1.Game.Skywars,
221
+ id: hive_bedrock_data_1.Game.SkyWars,
220
222
  xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
221
223
  played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
222
224
  victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
@@ -228,12 +230,13 @@ exports.processors = (_a = {},
228
230
  mystery_chests_destroyed: (_f = response.mystery_chests_destroyed) !== null && _f !== void 0 ? _f : 0,
229
231
  ores_mined: (_g = response.ores_mined) !== null && _g !== void 0 ? _g : 0,
230
232
  spells_used: (_h = response.spells_used) !== null && _h !== void 0 ? _h : 0,
233
+ prestige: (_j = response.prestige) !== null && _j !== void 0 ? _j : 0,
231
234
  });
232
235
  },
233
- _a[hive_bedrock_data_1.Game.SkywarsKits] = function (response) {
236
+ _a[hive_bedrock_data_1.Game.SkyWarsKits] = function (response) {
234
237
  var _a, _b, _c, _d, _e, _f, _g, _h;
235
238
  return ({
236
- id: hive_bedrock_data_1.Game.SkywarsKits,
239
+ id: hive_bedrock_data_1.Game.SkyWarsKits,
237
240
  xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
238
241
  played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
239
242
  victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
@@ -248,10 +251,10 @@ exports.processors = (_a = {},
248
251
  selected_kit: response.selected_kit,
249
252
  });
250
253
  },
251
- _a[hive_bedrock_data_1.Game.SkywarsClassic] = function (response) {
254
+ _a[hive_bedrock_data_1.Game.SkyWarsClassic] = function (response) {
252
255
  var _a, _b, _c, _d, _e;
253
256
  return ({
254
- id: hive_bedrock_data_1.Game.SkywarsClassic,
257
+ id: hive_bedrock_data_1.Game.SkyWarsClassic,
255
258
  xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
256
259
  played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
257
260
  victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
@@ -317,49 +320,51 @@ exports.processors = (_a = {},
317
320
  },
318
321
  _a[hive_bedrock_data_1.Game.ParkourWorlds] = function (response) {
319
322
  var _a;
320
- return ({
321
- id: hive_bedrock_data_1.Game.ParkourWorlds,
322
- worlds: Object.entries(response.parkours)
323
- .filter(function (_a) {
324
- var _b = __read(_a, 2), _ = _b[0], value = _b[1];
325
- return typeof value === "object";
326
- })
327
- .map(function (_a) {
328
- var _b;
329
- var _c = __read(_a, 2), key = _c[0], value = _c[1];
330
- return ({
331
- name: key,
332
- parkour_stars: (_b = value.parkour_stars) !== null && _b !== void 0 ? _b : 0,
333
- courses: Object.entries(value)
334
- .filter(function (_a) {
335
- var _b = __read(_a, 2), _ = _b[0], value = _b[1];
336
- return typeof value === "object";
337
- })
338
- .map(function (_a) {
339
- var _b;
340
- var _c = __read(_a, 2), key = _c[0], value = _c[1];
341
- return ({
342
- name: key,
343
- best_run_time: value.best_run_time,
344
- best_checkpoint_times: Object.entries(value.best_checkpoint_times).map(function (_a) {
345
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
346
- return ({
347
- position: { x: Number(key.split(",")[0]), y: Number(key.split(",")[1]), z: Number(key.split(",")[2]) },
348
- time: value,
349
- });
350
- }),
351
- collected_stars: value.collected_stars.map(function (value) { return ({
352
- x: Number(value.split(",")[0]),
353
- y: Number(value.split(",")[1]),
354
- z: Number(value.split(",")[2]),
355
- }); }),
356
- course_stars: (_b = value.course_stars) !== null && _b !== void 0 ? _b : 0,
357
- });
358
- }),
359
- });
360
- }),
361
- total_stars: (_a = response.parkours.total_stars) !== null && _a !== void 0 ? _a : 0,
362
- });
323
+ return response.parkours
324
+ ? {
325
+ id: hive_bedrock_data_1.Game.ParkourWorlds,
326
+ worlds: Object.entries(response.parkours)
327
+ .filter(function (_a) {
328
+ var _b = __read(_a, 2), _ = _b[0], value = _b[1];
329
+ return typeof value === "object";
330
+ })
331
+ .map(function (_a) {
332
+ var _b;
333
+ var _c = __read(_a, 2), key = _c[0], value = _c[1];
334
+ return ({
335
+ name: key,
336
+ parkour_stars: (_b = value.parkour_stars) !== null && _b !== void 0 ? _b : 0,
337
+ courses: Object.entries(value)
338
+ .filter(function (_a) {
339
+ var _b = __read(_a, 2), _ = _b[0], value = _b[1];
340
+ return typeof value === "object";
341
+ })
342
+ .map(function (_a) {
343
+ var _b;
344
+ var _c = __read(_a, 2), key = _c[0], value = _c[1];
345
+ return ({
346
+ name: key,
347
+ best_run_time: value.best_run_time,
348
+ best_checkpoint_times: Object.entries(value.best_checkpoint_times).map(function (_a) {
349
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
350
+ return ({
351
+ position: { x: Number(key.split(",")[0]), y: Number(key.split(",")[1]), z: Number(key.split(",")[2]) },
352
+ time: value,
353
+ });
354
+ }),
355
+ collected_stars: value.collected_stars.map(function (value) { return ({
356
+ x: Number(value.split(",")[0]),
357
+ y: Number(value.split(",")[1]),
358
+ z: Number(value.split(",")[2]),
359
+ }); }),
360
+ course_stars: (_b = value.course_stars) !== null && _b !== void 0 ? _b : 0,
361
+ });
362
+ }),
363
+ });
364
+ }),
365
+ total_stars: (_a = response.parkours.total_stars) !== null && _a !== void 0 ? _a : 0,
366
+ }
367
+ : null;
363
368
  },
364
369
  _a);
365
370
  function validateNumber(value, def) {
@@ -28,7 +28,7 @@ exports.AllTimeProcessors = (_a = {},
28
28
  _a[hive_bedrock_data_1.Game.Gravity] = grav_1.processAllTime_GRAV,
29
29
  _a[hive_bedrock_data_1.Game.GroundWars] = ground_1.processAllTime_GROUND,
30
30
  _a[hive_bedrock_data_1.Game.HideAndSeek] = hide_1.processAllTime_HIDE,
31
- _a[hive_bedrock_data_1.Game.JustBuild] = build_1.processAllTime_BUILD,
31
+ _a[hive_bedrock_data_1.Game.BuildBattle] = build_1.processAllTime_BUILD,
32
32
  _a[hive_bedrock_data_1.Game.MurderMystery] = murder_1.processAllTime_MURDER,
33
33
  _a[hive_bedrock_data_1.Game.ParkourWorlds] = parkour_1.processAllTime_PARKOUR,
34
34
  _a[hive_bedrock_data_1.Game.Skywars] = sky_1.processAllTime_SKY,
@@ -45,7 +45,7 @@ exports.MonthlyProcessors = (_b = {},
45
45
  _b[hive_bedrock_data_1.Game.Gravity] = grav_1.processMonthly_GRAV,
46
46
  _b[hive_bedrock_data_1.Game.GroundWars] = ground_1.processMonthly_GROUND,
47
47
  _b[hive_bedrock_data_1.Game.HideAndSeek] = hide_1.processMonthly_HIDE,
48
- _b[hive_bedrock_data_1.Game.JustBuild] = build_1.processMonthly_BUILD,
48
+ _b[hive_bedrock_data_1.Game.BuildBattle] = build_1.processMonthly_BUILD,
49
49
  _b[hive_bedrock_data_1.Game.MurderMystery] = murder_1.processMonthly_MURDER,
50
50
  _b[hive_bedrock_data_1.Game.Skywars] = sky_1.processMonthly_SKY,
51
51
  _b[hive_bedrock_data_1.Game.SurvivalGames] = sg_1.processMonthly_SG,
@@ -62,7 +62,7 @@ exports.LeaderboardProcessors = (_c = {},
62
62
  _c[hive_bedrock_data_1.Game.Gravity] = grav_1.processMonthly_GRAV,
63
63
  _c[hive_bedrock_data_1.Game.GroundWars] = ground_1.processMonthly_GROUND,
64
64
  _c[hive_bedrock_data_1.Game.HideAndSeek] = hide_1.processMonthly_HIDE,
65
- _c[hive_bedrock_data_1.Game.JustBuild] = build_1.processMonthly_BUILD,
65
+ _c[hive_bedrock_data_1.Game.BuildBattle] = build_1.processMonthly_BUILD,
66
66
  _c[hive_bedrock_data_1.Game.MurderMystery] = murder_1.processMonthly_MURDER,
67
67
  _c[hive_bedrock_data_1.Game.Skywars] = sky_1.processMonthly_SKY,
68
68
  _c[hive_bedrock_data_1.Game.SurvivalGames] = sg_1.processMonthly_SG,
@@ -13,26 +13,49 @@ export interface ProcessedPlayerResponse {
13
13
  quest_count: number;
14
14
  };
15
15
  equipped_cosmetics: {
16
- costume: string;
17
- avatar: {
18
- name: string;
19
- url: string;
20
- };
21
- hub_title: string;
22
- hat: string;
23
- backbling: string;
16
+ costume: CosmeticResponseTypes[CosmeticType.Costume];
17
+ avatar: CosmeticResponseTypes[CosmeticType.Avatar];
18
+ hub_title: CosmeticResponseTypes[CosmeticType.HubTitle];
19
+ hat: CosmeticResponseTypes[CosmeticType.Hat];
20
+ backbling: CosmeticResponseTypes[CosmeticType.Backbling];
24
21
  };
25
22
  owned_cosmetics: {
26
- costume: string[];
27
- avatar: {
28
- name: string;
29
- url: string;
30
- }[];
31
- hub_title: string[];
32
- hat: string[];
33
- pet: string[];
34
- mount: string[];
35
- backbling: string[];
23
+ costume: CosmeticResponseTypes[CosmeticType.Costume][];
24
+ avatar: CosmeticResponseTypes[CosmeticType.Avatar][];
25
+ hub_title: CosmeticResponseTypes[CosmeticType.HubTitle][];
26
+ hat: CosmeticResponseTypes[CosmeticType.Hat][];
27
+ pet: CosmeticResponseTypes[CosmeticType.Pet][];
28
+ mount: CosmeticResponseTypes[CosmeticType.Mount][];
29
+ backbling: CosmeticResponseTypes[CosmeticType.Backbling][];
30
+ };
31
+ }
32
+ export declare enum CosmeticType {
33
+ Costume = "costume",
34
+ Avatar = "avatar",
35
+ HubTitle = "hub_title",
36
+ Hat = "hat",
37
+ Pet = "pet",
38
+ Mount = "mount",
39
+ Backbling = "backbling"
40
+ }
41
+ export interface CosmeticResponseTypes {
42
+ [CosmeticType.Costume]: string;
43
+ [CosmeticType.Avatar]: {
44
+ name: string;
45
+ url: string;
46
+ };
47
+ [CosmeticType.HubTitle]: string;
48
+ [CosmeticType.Hat]: {
49
+ name: string;
50
+ icon: string;
51
+ rarity: string;
52
+ };
53
+ [CosmeticType.Pet]: string;
54
+ [CosmeticType.Mount]: string;
55
+ [CosmeticType.Backbling]: {
56
+ name: string;
57
+ icon: string;
58
+ rarity: string;
36
59
  };
37
60
  }
38
61
  export default function processPlayerInfo(playerResponse: any): ProcessedPlayerResponse | null;
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmeticType = void 0;
3
4
  exports.default = processPlayerInfo;
5
+ var CosmeticType;
6
+ (function (CosmeticType) {
7
+ CosmeticType["Costume"] = "costume";
8
+ CosmeticType["Avatar"] = "avatar";
9
+ CosmeticType["HubTitle"] = "hub_title";
10
+ CosmeticType["Hat"] = "hat";
11
+ CosmeticType["Pet"] = "pet";
12
+ CosmeticType["Mount"] = "mount";
13
+ CosmeticType["Backbling"] = "backbling";
14
+ })(CosmeticType || (exports.CosmeticType = CosmeticType = {}));
4
15
  function processPlayerInfo(playerResponse) {
5
16
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
6
17
  if (!playerResponse)
@@ -21,15 +21,15 @@ var processGameAndXP_1 = __importDefault(require("./helpers/processGameAndXP"));
21
21
  var processPlayedAndVictories_1 = __importDefault(require("./helpers/processPlayedAndVictories"));
22
22
  var processKillsAndDeaths_1 = __importDefault(require("./helpers/processKillsAndDeaths"));
23
23
  function processAllTime_SKY(statistics) {
24
- var _a, _b, _c, _d;
24
+ var _a, _b, _c, _d, _e;
25
25
  if (!statistics || Array.isArray(statistics))
26
26
  return null;
27
- return __assign(__assign(__assign(__assign({ UUID: statistics.UUID }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.Skywars, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processKillsAndDeaths_1.default)(statistics.kills, statistics.deaths)), { mystery_chests_destroyed: (_a = statistics.mystery_chests_destroyed) !== null && _a !== void 0 ? _a : 0, ores_mined: (_b = statistics.ores_mined) !== null && _b !== void 0 ? _b : 0, spells_used: (_c = statistics.spells_used) !== null && _c !== void 0 ? _c : 0, first_played: (_d = statistics.first_played) !== null && _d !== void 0 ? _d : null });
27
+ return __assign(__assign(__assign(__assign({ UUID: statistics.UUID }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.Skywars, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processKillsAndDeaths_1.default)(statistics.kills, statistics.deaths)), { mystery_chests_destroyed: (_a = statistics.mystery_chests_destroyed) !== null && _a !== void 0 ? _a : 0, ores_mined: (_b = statistics.ores_mined) !== null && _b !== void 0 ? _b : 0, spells_used: (_c = statistics.spells_used) !== null && _c !== void 0 ? _c : 0, prestige: (_d = statistics.prestige) !== null && _d !== void 0 ? _d : 0, first_played: (_e = statistics.first_played) !== null && _e !== void 0 ? _e : null });
28
28
  }
29
29
  function processMonthly_SKY(statistics) {
30
- var _a, _b, _c, _d, _e;
30
+ var _a, _b, _c, _d, _e, _f;
31
31
  if (!statistics || Array.isArray(statistics))
32
32
  return null;
33
33
  var index = (_a = statistics.index) !== null && _a !== void 0 ? _a : 0;
34
- return __assign(__assign(__assign(__assign({ index: (_b = statistics.index) !== null && _b !== void 0 ? _b : 0, human_index: index + 1, username: statistics.username }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.Skywars, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processKillsAndDeaths_1.default)(statistics.kills, statistics.deaths)), { mystery_chests_destroyed: (_c = statistics.mystery_chests_destroyed) !== null && _c !== void 0 ? _c : 0, ores_mined: (_d = statistics.ores_mined) !== null && _d !== void 0 ? _d : 0, spells_used: (_e = statistics.spells_used) !== null && _e !== void 0 ? _e : 0 });
34
+ return __assign(__assign(__assign(__assign({ index: (_b = statistics.index) !== null && _b !== void 0 ? _b : 0, human_index: index + 1, username: statistics.username }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.Skywars, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processKillsAndDeaths_1.default)(statistics.kills, statistics.deaths)), { mystery_chests_destroyed: (_c = statistics.mystery_chests_destroyed) !== null && _c !== void 0 ? _c : 0, ores_mined: (_d = statistics.ores_mined) !== null && _d !== void 0 ? _d : 0, spells_used: (_e = statistics.spells_used) !== null && _e !== void 0 ? _e : 0, prestige: (_f = statistics.prestige) !== null && _f !== void 0 ? _f : 0 });
35
35
  }
@@ -7,7 +7,7 @@ import { Processed_DeathRun_AllTimeStatistics, Processed_DeathRun_MonthlyStatist
7
7
  import { Processed_Gravity_AllTimeStatistics, Processed_Gravity_MonthlyStatistics } from "../processors/grav";
8
8
  import { Processed_GroundWars_AllTimeStatistics, Processed_GroundWars_MonthlyStatistics } from "../processors/ground";
9
9
  import { Processed_HideAndSeek_AllTimeStatistics, Processed_HideAndSeek_MonthlyStatistics } from "../processors/hide";
10
- import { Processed_JustBuild_AllTimeStatistics, Processed_JustBuild_MonthlyStatistics } from "../processors/build";
10
+ import { Processed_BuildBattle_AllTimeStatistics, Processed_BuildBattle_MonthlyStatistics } from "../processors/build";
11
11
  import { Processed_MurderMystery_AllTimeStatistics, Processed_MurderMystery_MonthlyStatistics } from "../processors/murder";
12
12
  import { Processed_ParkourWorlds_AllTimeStatistics } from "../processors/parkour";
13
13
  import { Processed_Skywars_AllTimeStatistics, Processed_Skywars_MonthlyStatistics } from "../processors/sky";
@@ -26,7 +26,7 @@ export interface AllTimeProcessedStatistics {
26
26
  [Game.Gravity]: Processed_Gravity_AllTimeStatistics;
27
27
  [Game.GroundWars]: Processed_GroundWars_AllTimeStatistics;
28
28
  [Game.HideAndSeek]: Processed_HideAndSeek_AllTimeStatistics;
29
- [Game.JustBuild]: Processed_JustBuild_AllTimeStatistics;
29
+ [Game.BuildBattle]: Processed_BuildBattle_AllTimeStatistics;
30
30
  [Game.MurderMystery]: Processed_MurderMystery_AllTimeStatistics;
31
31
  [Game.Skywars]: Processed_Skywars_AllTimeStatistics;
32
32
  [Game.SurvivalGames]: Processed_SurvivalGames_AllTimeStatistics;
@@ -49,7 +49,7 @@ export interface MonthlyProcessedStatistics {
49
49
  [Game.Gravity]: Processed_Gravity_MonthlyStatistics;
50
50
  [Game.GroundWars]: Processed_GroundWars_MonthlyStatistics;
51
51
  [Game.HideAndSeek]: Processed_HideAndSeek_MonthlyStatistics;
52
- [Game.JustBuild]: Processed_JustBuild_MonthlyStatistics;
52
+ [Game.BuildBattle]: Processed_BuildBattle_MonthlyStatistics;
53
53
  [Game.MurderMystery]: Processed_MurderMystery_MonthlyStatistics;
54
54
  [Game.Skywars]: Processed_Skywars_MonthlyStatistics;
55
55
  [Game.SurvivalGames]: Processed_SurvivalGames_MonthlyStatistics;
package/lib/utils.d.ts CHANGED
@@ -4,7 +4,6 @@ export interface MethodResponseError {
4
4
  }
5
5
  export type MethodResponse<D extends any> = {
6
6
  meta?: {
7
- /** sss */
8
7
  duration: number;
9
8
  ratelimit?: {
10
9
  limit: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hive-bedrock-api",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.20",
4
4
  "description": "An API wrapper for the Hive Minecraft Bedrock Edition server.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "license": "MIT",
12
12
  "author": "Cubeedge Studios",
13
13
  "dependencies": {
14
- "hive-bedrock-data": "^2.0.0-alpha.0"
14
+ "hive-bedrock-data": "^2.0.0-alpha.11"
15
15
  },
16
16
  "scripts": {
17
17
  "build": "tsc"