hive-bedrock-api 3.0.0-alpha.32 → 3.0.0-alpha.34
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/lib/index.js +40 -9
- package/lib/processors/game.d.ts +3 -0
- package/lib/processors/game.js +4 -1
- package/lib/processors/player.d.ts +1 -0
- package/lib/processors/player.js +1 -0
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -186,13 +186,18 @@ var HiveAPI = /** @class */ (function () {
|
|
|
186
186
|
return __awaiter(this, void 0, void 0, function () {
|
|
187
187
|
return __generator(this, function (_a) {
|
|
188
188
|
if (timeframe === hive_bedrock_data_1.Timeframe.AllTime) {
|
|
189
|
-
if (options === null || options === void 0 ? void 0 : options.game)
|
|
189
|
+
if (options === null || options === void 0 ? void 0 : options.game) {
|
|
190
|
+
if (!hive_bedrock_data_1.Games[options.game].statistics)
|
|
191
|
+
throw new Error("Statistics are not available for the game: ".concat(options.game));
|
|
190
192
|
return [2 /*return*/, this._getStatisticsAllTime(identifier, options.game)];
|
|
193
|
+
}
|
|
191
194
|
return [2 /*return*/, this._getStatisticsAllTime(identifier)];
|
|
192
195
|
}
|
|
193
196
|
else if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal) {
|
|
194
197
|
if (!(options === null || options === void 0 ? void 0 : options.game))
|
|
195
198
|
throw new Error("Game must be specified for seasonal statistics");
|
|
199
|
+
if (!hive_bedrock_data_1.Games[options.game].statistics)
|
|
200
|
+
throw new Error("Statistics are not available for the game: ".concat(options.game));
|
|
196
201
|
return [2 /*return*/, this._getStatisticsSeasonal(identifier, options === null || options === void 0 ? void 0 : options.game, (options === null || options === void 0 ? void 0 : options.season) || 1)];
|
|
197
202
|
}
|
|
198
203
|
if (options === null || options === void 0 ? void 0 : options.game)
|
|
@@ -236,7 +241,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
236
241
|
var _a, response, error, meta, data;
|
|
237
242
|
return __generator(this, function (_b) {
|
|
238
243
|
switch (_b.label) {
|
|
239
|
-
case 0:
|
|
244
|
+
case 0:
|
|
245
|
+
if (game && !hive_bedrock_data_1.Games[game].statistics)
|
|
246
|
+
throw new Error("Statistics are not available for the game: ".concat(game));
|
|
247
|
+
return [4 /*yield*/, this._fetchAPI("/game/monthly/player/".concat(game !== null && game !== void 0 ? game : "all", "/").concat(identifier, "/").concat(year !== null && year !== void 0 ? year : new Date().getFullYear(), "/").concat(month !== null && month !== void 0 ? month : new Date().getMonth() + 1))];
|
|
240
248
|
case 1:
|
|
241
249
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
242
250
|
if (error)
|
|
@@ -265,7 +273,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
265
273
|
var _a, response, error, meta;
|
|
266
274
|
return __generator(this, function (_b) {
|
|
267
275
|
switch (_b.label) {
|
|
268
|
-
case 0:
|
|
276
|
+
case 0:
|
|
277
|
+
if (!hive_bedrock_data_1.Games[game].statistics)
|
|
278
|
+
throw new Error("Statistics are not available for the game: ".concat(game));
|
|
279
|
+
return [4 /*yield*/, this._fetchAPI("/game/season/player/".concat(game, "/").concat(identifier, "/").concat(season !== null && season !== void 0 ? season : 1))];
|
|
269
280
|
case 1:
|
|
270
281
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
271
282
|
if (error)
|
|
@@ -303,7 +314,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
303
314
|
if (season === void 0) { season = 1; }
|
|
304
315
|
return __generator(this, function (_b) {
|
|
305
316
|
switch (_b.label) {
|
|
306
|
-
case 0:
|
|
317
|
+
case 0:
|
|
318
|
+
if (game && !hive_bedrock_data_1.Games[game].statistics)
|
|
319
|
+
throw new Error("Statistics are not available for the game: ".concat(game));
|
|
320
|
+
return [4 /*yield*/, this._fetchAPI("/game/season/player/".concat(game, "/").concat(identifier, "/").concat(season))];
|
|
307
321
|
case 1:
|
|
308
322
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
309
323
|
if (error)
|
|
@@ -317,6 +331,8 @@ var HiveAPI = /** @class */ (function () {
|
|
|
317
331
|
HiveAPI.prototype.getLeaderboard = function (timeframe, game, options) {
|
|
318
332
|
return __awaiter(this, void 0, void 0, function () {
|
|
319
333
|
return __generator(this, function (_a) {
|
|
334
|
+
if (game && !hive_bedrock_data_1.Games[game].statistics)
|
|
335
|
+
throw new Error("Statistics are not available for the game: ".concat(game));
|
|
320
336
|
if (timeframe === hive_bedrock_data_1.Timeframe.Monthly)
|
|
321
337
|
return [2 /*return*/, this._getLeaderboardMonthly(game, (options === null || options === void 0 ? void 0 : options.month) || new Date().getMonth() + 1, (options === null || options === void 0 ? void 0 : options.year) || new Date().getFullYear())];
|
|
322
338
|
if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal)
|
|
@@ -348,7 +364,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
348
364
|
var _a, response, error, meta, data;
|
|
349
365
|
return __generator(this, function (_b) {
|
|
350
366
|
switch (_b.label) {
|
|
351
|
-
case 0:
|
|
367
|
+
case 0:
|
|
368
|
+
if (game && !hive_bedrock_data_1.Games[game].statistics)
|
|
369
|
+
throw new Error("Statistics are not available for the game: ".concat(game));
|
|
370
|
+
return [4 /*yield*/, this._fetchAPI("/game/monthly/".concat(game, "/").concat(year, "/").concat(month))];
|
|
352
371
|
case 1:
|
|
353
372
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
354
373
|
if (error)
|
|
@@ -366,7 +385,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
366
385
|
if (season === void 0) { season = 1; }
|
|
367
386
|
return __generator(this, function (_b) {
|
|
368
387
|
switch (_b.label) {
|
|
369
|
-
case 0:
|
|
388
|
+
case 0:
|
|
389
|
+
if (game && !hive_bedrock_data_1.Games[game].statistics)
|
|
390
|
+
throw new Error("Statistics are not available for the game: ".concat(game));
|
|
391
|
+
return [4 /*yield*/, this._fetchAPI("/game/season/".concat(game, "/").concat(season))];
|
|
370
392
|
case 1:
|
|
371
393
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
372
394
|
if (error)
|
|
@@ -389,7 +411,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
389
411
|
if (season === void 0) { season = 1; }
|
|
390
412
|
return __generator(this, function (_b) {
|
|
391
413
|
switch (_b.label) {
|
|
392
|
-
case 0:
|
|
414
|
+
case 0:
|
|
415
|
+
if (game && !hive_bedrock_data_1.Games[game].statistics)
|
|
416
|
+
throw new Error("Statistics are not available for the game: ".concat(game));
|
|
417
|
+
return [4 /*yield*/, this._fetchAPI("/game/season/".concat(game, "/").concat(season !== null && season !== void 0 ? season : 1))];
|
|
393
418
|
case 1:
|
|
394
419
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
395
420
|
if (error)
|
|
@@ -429,7 +454,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
429
454
|
var _a, response, error, meta;
|
|
430
455
|
return __generator(this, function (_b) {
|
|
431
456
|
switch (_b.label) {
|
|
432
|
-
case 0:
|
|
457
|
+
case 0:
|
|
458
|
+
if (game && !hive_bedrock_data_1.Games[game].statistics)
|
|
459
|
+
throw new Error("Statistics are not available for the game: ".concat(game));
|
|
460
|
+
return [4 /*yield*/, this._fetchAPI("/game/map/".concat(game))];
|
|
433
461
|
case 1:
|
|
434
462
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
435
463
|
if (error)
|
|
@@ -449,7 +477,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
449
477
|
var _a, response, error, meta;
|
|
450
478
|
return __generator(this, function (_b) {
|
|
451
479
|
switch (_b.label) {
|
|
452
|
-
case 0:
|
|
480
|
+
case 0:
|
|
481
|
+
if (game && !hive_bedrock_data_1.Games[game].statistics)
|
|
482
|
+
throw new Error("Statistics are not available for the game: ".concat(game));
|
|
483
|
+
return [4 /*yield*/, this._fetchAPI("/game/meta/".concat(game))];
|
|
453
484
|
case 1:
|
|
454
485
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
455
486
|
if (error)
|
package/lib/processors/game.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface ProcessedGameBED {
|
|
|
12
12
|
kdr: number;
|
|
13
13
|
final_kills: number;
|
|
14
14
|
beds_destroyed: number;
|
|
15
|
+
prestige: number;
|
|
15
16
|
}
|
|
16
17
|
export interface ProcessedGameDROP {
|
|
17
18
|
id: Game.BlockDrop;
|
|
@@ -268,6 +269,8 @@ export interface ProcessedGame<T extends Timeframe, L extends boolean> {
|
|
|
268
269
|
[Game.TheBridge]: ProcessedGameBRIDGE & AdditionalStatistics<T, L>;
|
|
269
270
|
[Game.TreasureWars]: ProcessedGameWARS & AdditionalStatistics<T, L>;
|
|
270
271
|
[Game.ParkourWorlds]: L extends true ? never : T extends Timeframe.AllTime ? ProcessedGamePARKOUR : never;
|
|
272
|
+
[Game.MobGame]: never;
|
|
273
|
+
[Game.GhostInvasion]: never;
|
|
271
274
|
}
|
|
272
275
|
export declare function processGame<G extends Game, T extends Timeframe, L extends boolean>(game: G, timeframe: T, isLeaderboard: L, response: any): ProcessedGame<T, L>[G] | null;
|
|
273
276
|
export interface ProcessedAllGamesResponse {
|
package/lib/processors/game.js
CHANGED
|
@@ -46,7 +46,7 @@ function processGame(game, timeframe, isLeaderboard, response) {
|
|
|
46
46
|
}
|
|
47
47
|
var processors = (_a = {},
|
|
48
48
|
_a[hive_bedrock_data_1.Game.BedWars] = function (response) {
|
|
49
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
49
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
50
50
|
return ({
|
|
51
51
|
id: hive_bedrock_data_1.Game.BedWars,
|
|
52
52
|
xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
|
|
@@ -59,6 +59,7 @@ var processors = (_a = {},
|
|
|
59
59
|
kdr: calculateKDR(response.kills, response.deaths),
|
|
60
60
|
final_kills: (_f = response.final_kills) !== null && _f !== void 0 ? _f : 0,
|
|
61
61
|
beds_destroyed: (_g = response.beds_destroyed) !== null && _g !== void 0 ? _g : 0,
|
|
62
|
+
prestige: (_h = response.prestige) !== null && _h !== void 0 ? _h : 0,
|
|
62
63
|
});
|
|
63
64
|
},
|
|
64
65
|
_a[hive_bedrock_data_1.Game.BlockDrop] = function (response) {
|
|
@@ -359,6 +360,8 @@ var processors = (_a = {},
|
|
|
359
360
|
}
|
|
360
361
|
: null;
|
|
361
362
|
},
|
|
363
|
+
_a[hive_bedrock_data_1.Game.GhostInvasion] = function (_) { return null; },
|
|
364
|
+
_a[hive_bedrock_data_1.Game.MobGame] = function (_) { return null; },
|
|
362
365
|
_a);
|
|
363
366
|
function validateNumber(value, def) {
|
|
364
367
|
if (def === void 0) { def = 0; }
|
package/lib/processors/player.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hive-bedrock-api",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.34",
|
|
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.
|
|
14
|
+
"hive-bedrock-data": "^2.0.0-alpha.19"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "tsc"
|