hive-bedrock-api 3.0.0-alpha.9 → 4.0.1
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 +2 -2
- package/lib/index.d.ts +20 -4
- package/lib/index.js +127 -18
- package/lib/processors/game.d.ts +21 -32
- package/lib/processors/game.js +69 -63
- package/lib/processors/player.d.ts +42 -18
- package/lib/processors/player.js +12 -0
- package/lib/utils.d.ts +0 -1
- package/package.json +27 -26
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
|
|
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
|
|
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,12 +5,19 @@ 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
|
}
|
|
15
|
+
export * from "./processors/game";
|
|
16
|
+
export * from "./processors/global_statistics";
|
|
17
|
+
export * from "./processors/map";
|
|
18
|
+
export * from "./processors/meta";
|
|
19
|
+
export * from "./processors/player";
|
|
20
|
+
export * from "./processors/player_search";
|
|
14
21
|
export default class HiveAPI {
|
|
15
22
|
options: Options;
|
|
16
23
|
constructor(options?: Options);
|
|
@@ -41,14 +48,20 @@ export default class HiveAPI {
|
|
|
41
48
|
getStatistics(identifier: string, timeframe: Timeframe.Monthly, options?: {
|
|
42
49
|
month?: number;
|
|
43
50
|
year?: number;
|
|
44
|
-
}): Promise<MethodResponse<
|
|
51
|
+
}): Promise<MethodResponse<ProcessedMonthlyGamesResponse>>;
|
|
45
52
|
getStatistics<G extends Game>(identifier: string, timeframe: Timeframe.Monthly, options: {
|
|
46
53
|
game: G;
|
|
47
54
|
month?: number;
|
|
48
55
|
year?: number;
|
|
49
56
|
}): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, false>[G]>>;
|
|
57
|
+
getStatistics<G extends Game>(identifier: string, timeframe: Timeframe.Seasonal, options: {
|
|
58
|
+
game: G;
|
|
59
|
+
season: number;
|
|
60
|
+
}): Promise<MethodResponse<ProcessedMonthlyGamesResponse>>;
|
|
50
61
|
private _getStatisticsAllTime;
|
|
51
62
|
private _getStatisticsMonthly;
|
|
63
|
+
private _getStatisticsSeasonal;
|
|
64
|
+
getAvailableMonthlyLeaderboards<G extends Game>(game: G): Promise<MethodResponse<AvailableLeaderboardResponse>>;
|
|
52
65
|
/**
|
|
53
66
|
* `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
|
|
54
67
|
* @param identifier Username or UUID of the player
|
|
@@ -56,7 +69,7 @@ export default class HiveAPI {
|
|
|
56
69
|
* @param season The season to get the statistics for
|
|
57
70
|
* @returns The player's seasonal statistics
|
|
58
71
|
*/
|
|
59
|
-
getSeasonalStatistics<G extends Game>(identifier: string, game: G, season?: number): Promise<MethodResponse<
|
|
72
|
+
getSeasonalStatistics<G extends Game>(identifier: string, game: G, season?: number): Promise<MethodResponse<ProcessedMonthlyGamesResponse["statistics"][G] | null>>;
|
|
60
73
|
/**
|
|
61
74
|
* `/game/all/{game}` Gets statistics for a game
|
|
62
75
|
* @param timeframe The timeframe to get the statistics for
|
|
@@ -69,8 +82,12 @@ export default class HiveAPI {
|
|
|
69
82
|
month?: number;
|
|
70
83
|
year?: number;
|
|
71
84
|
}): Promise<MethodResponse<ProcessedGame<Timeframe.Monthly, true>[G][] | null>>;
|
|
85
|
+
getLeaderboard<G extends Game>(timeframe: Timeframe.Seasonal, game: G, options: {
|
|
86
|
+
season: number;
|
|
87
|
+
}): Promise<MethodResponse<ProcessedGame<Timeframe.Seasonal, true>[G][] | null>>;
|
|
72
88
|
private _getLeaderboardAllTime;
|
|
73
89
|
private _getLeaderboardMonthly;
|
|
90
|
+
private _getLeaderboardSeasonal;
|
|
74
91
|
/**
|
|
75
92
|
* `/game/season/{game}/{season}` Gets seasonal statistics for a game
|
|
76
93
|
* @param game The game to get the statistics for
|
|
@@ -96,4 +113,3 @@ export default class HiveAPI {
|
|
|
96
113
|
*/
|
|
97
114
|
getGameMetadata(game: Game): Promise<MethodResponse<ProcessedGameMetadata>>;
|
|
98
115
|
}
|
|
99
|
-
export {};
|
package/lib/index.js
CHANGED
|
@@ -10,6 +10,20 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
+
};
|
|
13
27
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
28
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
29
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -69,11 +83,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
69
83
|
var hive_bedrock_data_1 = require("hive-bedrock-data");
|
|
70
84
|
var player_1 = __importDefault(require("./processors/player"));
|
|
71
85
|
var player_search_1 = __importDefault(require("./processors/player_search"));
|
|
72
|
-
var game_1 =
|
|
86
|
+
var game_1 = require("./processors/game");
|
|
87
|
+
__exportStar(require("./processors/game"), exports);
|
|
88
|
+
__exportStar(require("./processors/global_statistics"), exports);
|
|
89
|
+
__exportStar(require("./processors/map"), exports);
|
|
90
|
+
__exportStar(require("./processors/meta"), exports);
|
|
91
|
+
__exportStar(require("./processors/player"), exports);
|
|
92
|
+
__exportStar(require("./processors/player_search"), exports);
|
|
73
93
|
var HiveAPI = /** @class */ (function () {
|
|
74
94
|
function HiveAPI(options) {
|
|
75
|
-
if (options === void 0) { options = {
|
|
95
|
+
if (options === void 0) { options = {}; }
|
|
96
|
+
var _a;
|
|
76
97
|
this.options = options;
|
|
98
|
+
this.options = options;
|
|
99
|
+
this.options.apiBaseEndpoint = (_a = this.options.apiBaseEndpoint) !== null && _a !== void 0 ? _a : hive_bedrock_data_1.API_BASE_ENDPOINT;
|
|
77
100
|
}
|
|
78
101
|
HiveAPI.prototype._fetchAPI = function (endpoint) {
|
|
79
102
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -87,7 +110,7 @@ var HiveAPI = /** @class */ (function () {
|
|
|
87
110
|
case 1:
|
|
88
111
|
_c.trys.push([1, 4, , 5]);
|
|
89
112
|
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) }))];
|
|
113
|
+
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
114
|
case 2:
|
|
92
115
|
request = _c.sent();
|
|
93
116
|
if (!request.ok)
|
|
@@ -163,10 +186,20 @@ var HiveAPI = /** @class */ (function () {
|
|
|
163
186
|
return __awaiter(this, void 0, void 0, function () {
|
|
164
187
|
return __generator(this, function (_a) {
|
|
165
188
|
if (timeframe === hive_bedrock_data_1.Timeframe.AllTime) {
|
|
166
|
-
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));
|
|
167
192
|
return [2 /*return*/, this._getStatisticsAllTime(identifier, options.game)];
|
|
193
|
+
}
|
|
168
194
|
return [2 /*return*/, this._getStatisticsAllTime(identifier)];
|
|
169
195
|
}
|
|
196
|
+
else if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal) {
|
|
197
|
+
if (!(options === null || options === void 0 ? void 0 : options.game))
|
|
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));
|
|
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)];
|
|
202
|
+
}
|
|
170
203
|
if (options === null || options === void 0 ? void 0 : options.game)
|
|
171
204
|
return [2 /*return*/, this._getStatisticsMonthly(identifier, options.game, options.month, options.year)];
|
|
172
205
|
return [2 /*return*/, this._getStatisticsMonthly(identifier, undefined, options === null || options === void 0 ? void 0 : options.month, options === null || options === void 0 ? void 0 : options.year)];
|
|
@@ -184,11 +217,11 @@ var HiveAPI = /** @class */ (function () {
|
|
|
184
217
|
if (error)
|
|
185
218
|
return [2 /*return*/, { data: null, error: error, meta: meta }];
|
|
186
219
|
if (game)
|
|
187
|
-
return [2 /*return*/, { data: (0, game_1.
|
|
220
|
+
return [2 /*return*/, { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.AllTime, false, response), error: null, meta: meta }];
|
|
188
221
|
data = Object.fromEntries(Object.entries(response).map(function (_a) {
|
|
189
222
|
var _b;
|
|
190
223
|
var _c = __read(_a, 2), id = _c[0], res = _c[1];
|
|
191
|
-
return [id, id === "main" ? null : (_b = (0, game_1.
|
|
224
|
+
return [id, id === "main" ? null : (_b = (0, game_1.processGame)(id, hive_bedrock_data_1.Timeframe.AllTime, false, res)) !== null && _b !== void 0 ? _b : null];
|
|
192
225
|
}));
|
|
193
226
|
delete data.main;
|
|
194
227
|
return [2 /*return*/, {
|
|
@@ -208,17 +241,20 @@ var HiveAPI = /** @class */ (function () {
|
|
|
208
241
|
var _a, response, error, meta, data;
|
|
209
242
|
return __generator(this, function (_b) {
|
|
210
243
|
switch (_b.label) {
|
|
211
|
-
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))];
|
|
212
248
|
case 1:
|
|
213
249
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
214
250
|
if (error)
|
|
215
251
|
return [2 /*return*/, { data: null, error: error, meta: meta }];
|
|
216
252
|
if (game)
|
|
217
|
-
return [2 /*return*/, { data: (0, game_1.
|
|
253
|
+
return [2 /*return*/, { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, false, response), error: null, meta: meta }];
|
|
218
254
|
data = Object.fromEntries(Object.entries(response).map(function (_a) {
|
|
219
255
|
var _b;
|
|
220
256
|
var _c = __read(_a, 2), id = _c[0], res = _c[1];
|
|
221
|
-
return [id, id === "main" ? null : (_b = (0, game_1.
|
|
257
|
+
return [id, id === "main" ? null : (_b = (0, game_1.processGame)(id, hive_bedrock_data_1.Timeframe.Monthly, false, res)) !== null && _b !== void 0 ? _b : null];
|
|
222
258
|
}));
|
|
223
259
|
delete data.main;
|
|
224
260
|
return [2 /*return*/, {
|
|
@@ -232,6 +268,39 @@ var HiveAPI = /** @class */ (function () {
|
|
|
232
268
|
});
|
|
233
269
|
});
|
|
234
270
|
};
|
|
271
|
+
HiveAPI.prototype._getStatisticsSeasonal = function (identifier, game, season) {
|
|
272
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
273
|
+
var _a, response, error, meta;
|
|
274
|
+
return __generator(this, function (_b) {
|
|
275
|
+
switch (_b.label) {
|
|
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))];
|
|
280
|
+
case 1:
|
|
281
|
+
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
282
|
+
if (error)
|
|
283
|
+
return [2 /*return*/, { data: null, error: error, meta: meta }];
|
|
284
|
+
return [2 /*return*/, { data: (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Seasonal, false, response), error: null, meta: meta }];
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
HiveAPI.prototype.getAvailableMonthlyLeaderboards = function (game) {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
291
|
+
var _a, response, error, meta;
|
|
292
|
+
return __generator(this, function (_b) {
|
|
293
|
+
switch (_b.label) {
|
|
294
|
+
case 0: return [4 /*yield*/, this._fetchAPI("/game/monthly/".concat(game, "/available"))];
|
|
295
|
+
case 1:
|
|
296
|
+
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
297
|
+
if (error)
|
|
298
|
+
return [2 /*return*/, { data: null, error: error, meta: meta }];
|
|
299
|
+
return [2 /*return*/, { data: response, error: null, meta: meta }];
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
};
|
|
235
304
|
/**
|
|
236
305
|
* `/game/season/player/{game}/{player}/{season}` Gets seasonal statistics for a player
|
|
237
306
|
* @param identifier Username or UUID of the player
|
|
@@ -245,12 +314,15 @@ var HiveAPI = /** @class */ (function () {
|
|
|
245
314
|
if (season === void 0) { season = 1; }
|
|
246
315
|
return __generator(this, function (_b) {
|
|
247
316
|
switch (_b.label) {
|
|
248
|
-
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))];
|
|
249
321
|
case 1:
|
|
250
322
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
251
323
|
if (error)
|
|
252
324
|
return [2 /*return*/, { data: null, error: error, meta: meta }];
|
|
253
|
-
data = (0, game_1.
|
|
325
|
+
data = (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, response);
|
|
254
326
|
return [2 /*return*/, { data: data, error: null, meta: meta }];
|
|
255
327
|
}
|
|
256
328
|
});
|
|
@@ -259,8 +331,12 @@ var HiveAPI = /** @class */ (function () {
|
|
|
259
331
|
HiveAPI.prototype.getLeaderboard = function (timeframe, game, options) {
|
|
260
332
|
return __awaiter(this, void 0, void 0, function () {
|
|
261
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));
|
|
262
336
|
if (timeframe === hive_bedrock_data_1.Timeframe.Monthly)
|
|
263
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())];
|
|
338
|
+
if (timeframe === hive_bedrock_data_1.Timeframe.Seasonal)
|
|
339
|
+
return [2 /*return*/, this._getLeaderboardSeasonal(game, (options === null || options === void 0 ? void 0 : options.season) || 1)];
|
|
264
340
|
return [2 /*return*/, this._getLeaderboardAllTime(game)];
|
|
265
341
|
});
|
|
266
342
|
});
|
|
@@ -276,7 +352,7 @@ var HiveAPI = /** @class */ (function () {
|
|
|
276
352
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
277
353
|
if (error)
|
|
278
354
|
return [2 /*return*/, { data: null, error: error, meta: meta }];
|
|
279
|
-
data = response.map(function (res) { return (0, game_1.
|
|
355
|
+
data = response.map(function (res) { return (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.AllTime, true, res); });
|
|
280
356
|
return [2 /*return*/, { data: data, error: null, meta: meta }];
|
|
281
357
|
}
|
|
282
358
|
});
|
|
@@ -288,12 +364,36 @@ var HiveAPI = /** @class */ (function () {
|
|
|
288
364
|
var _a, response, error, meta, data;
|
|
289
365
|
return __generator(this, function (_b) {
|
|
290
366
|
switch (_b.label) {
|
|
291
|
-
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))];
|
|
292
371
|
case 1:
|
|
293
372
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
294
373
|
if (error)
|
|
295
374
|
return [2 /*return*/, { data: null, error: error, meta: meta }];
|
|
296
|
-
data = response.map(function (res) { return (0, game_1.
|
|
375
|
+
data = response.map(function (res) { return (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, res); });
|
|
376
|
+
return [2 /*return*/, { data: data, error: null, meta: meta }];
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
};
|
|
381
|
+
// /game/season/{game}/season
|
|
382
|
+
HiveAPI.prototype._getLeaderboardSeasonal = function (game_2) {
|
|
383
|
+
return __awaiter(this, arguments, void 0, function (game, season) {
|
|
384
|
+
var _a, response, error, meta, data;
|
|
385
|
+
if (season === void 0) { season = 1; }
|
|
386
|
+
return __generator(this, function (_b) {
|
|
387
|
+
switch (_b.label) {
|
|
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))];
|
|
392
|
+
case 1:
|
|
393
|
+
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
394
|
+
if (error)
|
|
395
|
+
return [2 /*return*/, { data: null, error: error, meta: meta }];
|
|
396
|
+
data = response.map(function (res) { return (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Seasonal, true, res); });
|
|
297
397
|
return [2 /*return*/, { data: data, error: null, meta: meta }];
|
|
298
398
|
}
|
|
299
399
|
});
|
|
@@ -311,12 +411,15 @@ var HiveAPI = /** @class */ (function () {
|
|
|
311
411
|
if (season === void 0) { season = 1; }
|
|
312
412
|
return __generator(this, function (_b) {
|
|
313
413
|
switch (_b.label) {
|
|
314
|
-
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))];
|
|
315
418
|
case 1:
|
|
316
419
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
317
420
|
if (error)
|
|
318
421
|
return [2 /*return*/, { data: null, error: error, meta: meta }];
|
|
319
|
-
data = response.map(function (res) { return (0, game_1.
|
|
422
|
+
data = response.map(function (res) { return (0, game_1.processGame)(game, hive_bedrock_data_1.Timeframe.Monthly, true, res); });
|
|
320
423
|
return [2 /*return*/, { data: data, error: null, meta: meta }];
|
|
321
424
|
}
|
|
322
425
|
});
|
|
@@ -351,7 +454,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
351
454
|
var _a, response, error, meta;
|
|
352
455
|
return __generator(this, function (_b) {
|
|
353
456
|
switch (_b.label) {
|
|
354
|
-
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))];
|
|
355
461
|
case 1:
|
|
356
462
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
357
463
|
if (error)
|
|
@@ -371,7 +477,10 @@ var HiveAPI = /** @class */ (function () {
|
|
|
371
477
|
var _a, response, error, meta;
|
|
372
478
|
return __generator(this, function (_b) {
|
|
373
479
|
switch (_b.label) {
|
|
374
|
-
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))];
|
|
375
484
|
case 1:
|
|
376
485
|
_a = _b.sent(), response = _a.data, error = _a.error, meta = _a.meta;
|
|
377
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;
|
|
@@ -88,7 +89,7 @@ export interface ProcessedGameGROUND {
|
|
|
88
89
|
projectiles_fired: number;
|
|
89
90
|
}
|
|
90
91
|
export interface ProcessedGameBUILD {
|
|
91
|
-
id: Game.
|
|
92
|
+
id: Game.BuildBattle;
|
|
92
93
|
xp: number;
|
|
93
94
|
played: number;
|
|
94
95
|
victories: number;
|
|
@@ -111,7 +112,7 @@ export interface ProcessedGameHIDE {
|
|
|
111
112
|
deaths: number;
|
|
112
113
|
hider_kills: number;
|
|
113
114
|
seeker_kills: number;
|
|
114
|
-
|
|
115
|
+
kpg: number;
|
|
115
116
|
}
|
|
116
117
|
export interface ProcessedGameMURDER {
|
|
117
118
|
id: Game.MurderMystery;
|
|
@@ -122,7 +123,7 @@ export interface ProcessedGameMURDER {
|
|
|
122
123
|
win_percentage: number;
|
|
123
124
|
murders: number;
|
|
124
125
|
deaths: number;
|
|
125
|
-
|
|
126
|
+
edr: number;
|
|
126
127
|
coins: number;
|
|
127
128
|
murderer_eliminations: number;
|
|
128
129
|
prestige: number;
|
|
@@ -140,6 +141,7 @@ export interface ProcessedGameSKY {
|
|
|
140
141
|
mystery_chests_destroyed: number;
|
|
141
142
|
ores_mined: number;
|
|
142
143
|
spells_used: number;
|
|
144
|
+
prestige: number;
|
|
143
145
|
}
|
|
144
146
|
export interface ProcessedGameSKYKITS {
|
|
145
147
|
id: Game.SkyWarsKits;
|
|
@@ -241,7 +243,10 @@ export type AdditionalStatistics<T extends Timeframe, L extends boolean> = (T ex
|
|
|
241
243
|
level: number;
|
|
242
244
|
} & (L extends true ? {} : {
|
|
243
245
|
first_played: number;
|
|
244
|
-
}) : {
|
|
246
|
+
}) : {
|
|
247
|
+
position: number;
|
|
248
|
+
username: string;
|
|
249
|
+
}) & (L extends true ? {
|
|
245
250
|
position: number;
|
|
246
251
|
username: string;
|
|
247
252
|
UUID: string;
|
|
@@ -254,7 +259,7 @@ export interface ProcessedGame<T extends Timeframe, L extends boolean> {
|
|
|
254
259
|
[Game.DeathRun]: ProcessedGameDR & AdditionalStatistics<T, L>;
|
|
255
260
|
[Game.Gravity]: ProcessedGameGRAV & AdditionalStatistics<T, L>;
|
|
256
261
|
[Game.GroundWars]: ProcessedGameGROUND & AdditionalStatistics<T, L>;
|
|
257
|
-
[Game.
|
|
262
|
+
[Game.BuildBattle]: ProcessedGameBUILD & AdditionalStatistics<T, L>;
|
|
258
263
|
[Game.HideAndSeek]: ProcessedGameHIDE & AdditionalStatistics<T, L>;
|
|
259
264
|
[Game.MurderMystery]: ProcessedGameMURDER & AdditionalStatistics<T, L>;
|
|
260
265
|
[Game.SkyWars]: ProcessedGameSKY & AdditionalStatistics<T, L>;
|
|
@@ -263,34 +268,11 @@ export interface ProcessedGame<T extends Timeframe, L extends boolean> {
|
|
|
263
268
|
[Game.SurvivalGames]: ProcessedGameSG & AdditionalStatistics<T, L>;
|
|
264
269
|
[Game.TheBridge]: ProcessedGameBRIDGE & AdditionalStatistics<T, L>;
|
|
265
270
|
[Game.TreasureWars]: ProcessedGameWARS & AdditionalStatistics<T, L>;
|
|
266
|
-
[Game.ParkourWorlds]: L extends true ? never : T extends Timeframe.
|
|
271
|
+
[Game.ParkourWorlds]: L extends true ? never : T extends Timeframe.AllTime ? ProcessedGamePARKOUR : never;
|
|
272
|
+
[Game.MobGame]: never;
|
|
273
|
+
[Game.GhostInvasion]: never;
|
|
267
274
|
}
|
|
268
|
-
export
|
|
269
|
-
export declare const processors: {
|
|
270
|
-
bed: (response: any) => ProcessedGameBED;
|
|
271
|
-
drop: (response: any) => ProcessedGameDROP;
|
|
272
|
-
party: (response: any) => ProcessedGamePARTY;
|
|
273
|
-
ctf: (response: any) => ProcessedGameCTF;
|
|
274
|
-
dr: (response: any) => ProcessedGameDR;
|
|
275
|
-
grav: (response: any) => ProcessedGameGRAV;
|
|
276
|
-
ground: (response: any) => ProcessedGameGROUND;
|
|
277
|
-
build: (response: any) => ProcessedGameBUILD;
|
|
278
|
-
hide: (response: any) => ProcessedGameHIDE;
|
|
279
|
-
murder: (response: any) => ProcessedGameMURDER;
|
|
280
|
-
sky: (response: any) => ProcessedGameSKY;
|
|
281
|
-
"sky-kits": (response: any) => ProcessedGameSKYKITS;
|
|
282
|
-
"sky-classic": (response: any) => ProcessedGameSKYCLASSIC;
|
|
283
|
-
sg: (response: any) => ProcessedGameSG;
|
|
284
|
-
bridge: (response: any) => ProcessedGameBRIDGE;
|
|
285
|
-
wars: (response: any) => ProcessedGameWARS;
|
|
286
|
-
parkour: (response: any) => ProcessedGamePARKOUR;
|
|
287
|
-
};
|
|
288
|
-
export declare function validateNumber(value: number, def?: number): number;
|
|
289
|
-
export declare function calculateKDR(kills: number, deaths: number): number;
|
|
290
|
-
export declare function calculateWinPercentage(victories: number, played: number): number;
|
|
291
|
-
export declare function calculateLosses(played: number, victories: number): number;
|
|
292
|
-
export declare function calculateTotal(values: number[]): number;
|
|
293
|
-
export declare function roundTo(value: number, places?: number): number;
|
|
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;
|
|
294
276
|
export interface ProcessedAllGamesResponse {
|
|
295
277
|
player: ProcessedPlayerResponse;
|
|
296
278
|
statistics: {
|
|
@@ -302,3 +284,10 @@ export interface ProcessedMonthlyGamesResponse {
|
|
|
302
284
|
[G in Game]: ProcessedGame<Timeframe.Monthly, false>[G] | null;
|
|
303
285
|
};
|
|
304
286
|
}
|
|
287
|
+
export interface AvailableLeaderboard {
|
|
288
|
+
month: string;
|
|
289
|
+
year: string;
|
|
290
|
+
month_number: number;
|
|
291
|
+
resource: string;
|
|
292
|
+
}
|
|
293
|
+
export type AvailableLeaderboardResponse = AvailableLeaderboard[];
|
package/lib/processors/game.js
CHANGED
|
@@ -17,14 +17,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
17
17
|
};
|
|
18
18
|
var _a;
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
21
|
-
exports.default = processGame;
|
|
22
|
-
exports.validateNumber = validateNumber;
|
|
23
|
-
exports.calculateKDR = calculateKDR;
|
|
24
|
-
exports.calculateWinPercentage = calculateWinPercentage;
|
|
25
|
-
exports.calculateLosses = calculateLosses;
|
|
26
|
-
exports.calculateTotal = calculateTotal;
|
|
27
|
-
exports.roundTo = roundTo;
|
|
20
|
+
exports.processGame = processGame;
|
|
28
21
|
var hive_bedrock_data_1 = require("hive-bedrock-data");
|
|
29
22
|
function processGame(game, timeframe, isLeaderboard, response) {
|
|
30
23
|
var _a;
|
|
@@ -34,24 +27,26 @@ function processGame(game, timeframe, isLeaderboard, response) {
|
|
|
34
27
|
return null;
|
|
35
28
|
if (Array.isArray(response))
|
|
36
29
|
return null;
|
|
37
|
-
var data =
|
|
38
|
-
if (
|
|
30
|
+
var data = processors[game](response);
|
|
31
|
+
if (!data)
|
|
32
|
+
return null;
|
|
33
|
+
if ("played" in data && data.played === 0 && "xp" in data && data.xp === 0)
|
|
39
34
|
return null;
|
|
40
35
|
if (timeframe === hive_bedrock_data_1.Timeframe.AllTime && "xp" in data)
|
|
41
36
|
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
|
|
37
|
+
if (timeframe === hive_bedrock_data_1.Timeframe.AllTime && "first_played" in response)
|
|
43
38
|
data.first_played = response.first_played;
|
|
44
|
-
if (isLeaderboard && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
|
|
39
|
+
if ((isLeaderboard || timeframe !== hive_bedrock_data_1.Timeframe.AllTime) && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
|
|
45
40
|
data.position = response.human_index;
|
|
46
|
-
if (isLeaderboard && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
|
|
41
|
+
if ((isLeaderboard || timeframe !== hive_bedrock_data_1.Timeframe.AllTime) && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
|
|
47
42
|
data.username = response.username;
|
|
48
43
|
if (isLeaderboard && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
|
|
49
44
|
data.UUID = response.UUID;
|
|
50
45
|
return data;
|
|
51
46
|
}
|
|
52
|
-
|
|
47
|
+
var processors = (_a = {},
|
|
53
48
|
_a[hive_bedrock_data_1.Game.BedWars] = function (response) {
|
|
54
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
49
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
55
50
|
return ({
|
|
56
51
|
id: hive_bedrock_data_1.Game.BedWars,
|
|
57
52
|
xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
|
|
@@ -64,6 +59,7 @@ exports.processors = (_a = {},
|
|
|
64
59
|
kdr: calculateKDR(response.kills, response.deaths),
|
|
65
60
|
final_kills: (_f = response.final_kills) !== null && _f !== void 0 ? _f : 0,
|
|
66
61
|
beds_destroyed: (_g = response.beds_destroyed) !== null && _g !== void 0 ? _g : 0,
|
|
62
|
+
prestige: (_h = response.prestige) !== null && _h !== void 0 ? _h : 0,
|
|
67
63
|
});
|
|
68
64
|
},
|
|
69
65
|
_a[hive_bedrock_data_1.Game.BlockDrop] = function (response) {
|
|
@@ -158,10 +154,10 @@ exports.processors = (_a = {},
|
|
|
158
154
|
projectiles_fired: (_h = response.projectiles_fired) !== null && _h !== void 0 ? _h : 0,
|
|
159
155
|
});
|
|
160
156
|
},
|
|
161
|
-
_a[hive_bedrock_data_1.Game.
|
|
157
|
+
_a[hive_bedrock_data_1.Game.BuildBattle] = function (response) {
|
|
162
158
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
163
159
|
return ({
|
|
164
|
-
id: hive_bedrock_data_1.Game.
|
|
160
|
+
id: hive_bedrock_data_1.Game.BuildBattle,
|
|
165
161
|
xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
|
|
166
162
|
played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
|
|
167
163
|
victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
|
|
@@ -192,7 +188,7 @@ exports.processors = (_a = {},
|
|
|
192
188
|
win_percentage: calculateWinPercentage(response.victories, response.played),
|
|
193
189
|
deaths: (_d = response.deaths) !== null && _d !== void 0 ? _d : 0,
|
|
194
190
|
hider_kills: (_e = response.hider_kills) !== null && _e !== void 0 ? _e : 0,
|
|
195
|
-
|
|
191
|
+
kpg: calculateKPG(response.hider_kills, response.played),
|
|
196
192
|
seeker_kills: (_f = response.seeker_kills) !== null && _f !== void 0 ? _f : 0,
|
|
197
193
|
});
|
|
198
194
|
},
|
|
@@ -207,14 +203,14 @@ exports.processors = (_a = {},
|
|
|
207
203
|
win_percentage: calculateWinPercentage(response.victories, response.played),
|
|
208
204
|
murders: (_d = response.murders) !== null && _d !== void 0 ? _d : 0,
|
|
209
205
|
deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
|
|
210
|
-
|
|
206
|
+
edr: calculateKDR(response.murderer_eliminations, response.deaths),
|
|
211
207
|
coins: (_f = response.coins) !== null && _f !== void 0 ? _f : 0,
|
|
212
208
|
murderer_eliminations: (_g = response.murderer_eliminations) !== null && _g !== void 0 ? _g : 0,
|
|
213
209
|
prestige: (_h = response.prestige) !== null && _h !== void 0 ? _h : 0,
|
|
214
210
|
});
|
|
215
211
|
},
|
|
216
212
|
_a[hive_bedrock_data_1.Game.SkyWars] = function (response) {
|
|
217
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
213
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
218
214
|
return ({
|
|
219
215
|
id: hive_bedrock_data_1.Game.SkyWars,
|
|
220
216
|
xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
|
|
@@ -228,6 +224,7 @@ exports.processors = (_a = {},
|
|
|
228
224
|
mystery_chests_destroyed: (_f = response.mystery_chests_destroyed) !== null && _f !== void 0 ? _f : 0,
|
|
229
225
|
ores_mined: (_g = response.ores_mined) !== null && _g !== void 0 ? _g : 0,
|
|
230
226
|
spells_used: (_h = response.spells_used) !== null && _h !== void 0 ? _h : 0,
|
|
227
|
+
prestige: (_j = response.prestige) !== null && _j !== void 0 ? _j : 0,
|
|
231
228
|
});
|
|
232
229
|
},
|
|
233
230
|
_a[hive_bedrock_data_1.Game.SkyWarsKits] = function (response) {
|
|
@@ -317,50 +314,54 @@ exports.processors = (_a = {},
|
|
|
317
314
|
},
|
|
318
315
|
_a[hive_bedrock_data_1.Game.ParkourWorlds] = function (response) {
|
|
319
316
|
var _a;
|
|
320
|
-
return
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
.
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
317
|
+
return response.parkours
|
|
318
|
+
? {
|
|
319
|
+
id: hive_bedrock_data_1.Game.ParkourWorlds,
|
|
320
|
+
worlds: Object.entries(response.parkours)
|
|
321
|
+
.filter(function (_a) {
|
|
322
|
+
var _b = __read(_a, 2), _ = _b[0], value = _b[1];
|
|
323
|
+
return typeof value === "object";
|
|
324
|
+
})
|
|
325
|
+
.map(function (_a) {
|
|
326
|
+
var _b;
|
|
327
|
+
var _c = __read(_a, 2), key = _c[0], value = _c[1];
|
|
328
|
+
return ({
|
|
329
|
+
name: key,
|
|
330
|
+
parkour_stars: (_b = value.parkour_stars) !== null && _b !== void 0 ? _b : 0,
|
|
331
|
+
courses: Object.entries(value)
|
|
332
|
+
.filter(function (_a) {
|
|
333
|
+
var _b = __read(_a, 2), _ = _b[0], value = _b[1];
|
|
334
|
+
return typeof value === "object";
|
|
335
|
+
})
|
|
336
|
+
.map(function (_a) {
|
|
337
|
+
var _b;
|
|
338
|
+
var _c = __read(_a, 2), key = _c[0], value = _c[1];
|
|
339
|
+
return ({
|
|
340
|
+
name: key,
|
|
341
|
+
best_run_time: value.best_run_time,
|
|
342
|
+
best_checkpoint_times: Object.entries(value.best_checkpoint_times).map(function (_a) {
|
|
343
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
344
|
+
return ({
|
|
345
|
+
position: { x: Number(key.split(",")[0]), y: Number(key.split(",")[1]), z: Number(key.split(",")[2]) },
|
|
346
|
+
time: value,
|
|
347
|
+
});
|
|
348
|
+
}),
|
|
349
|
+
collected_stars: value.collected_stars.map(function (value) { return ({
|
|
350
|
+
x: Number(value.split(",")[0]),
|
|
351
|
+
y: Number(value.split(",")[1]),
|
|
352
|
+
z: Number(value.split(",")[2]),
|
|
353
|
+
}); }),
|
|
354
|
+
course_stars: (_b = value.course_stars) !== null && _b !== void 0 ? _b : 0,
|
|
355
|
+
});
|
|
356
|
+
}),
|
|
357
|
+
});
|
|
358
|
+
}),
|
|
359
|
+
total_stars: (_a = response.parkours.total_stars) !== null && _a !== void 0 ? _a : 0,
|
|
360
|
+
}
|
|
361
|
+
: null;
|
|
363
362
|
},
|
|
363
|
+
_a[hive_bedrock_data_1.Game.GhostInvasion] = function (_) { return null; },
|
|
364
|
+
_a[hive_bedrock_data_1.Game.MobGame] = function (_) { return null; },
|
|
364
365
|
_a);
|
|
365
366
|
function validateNumber(value, def) {
|
|
366
367
|
if (def === void 0) { def = 0; }
|
|
@@ -384,6 +385,11 @@ function calculateLosses(played, victories) {
|
|
|
384
385
|
function calculateTotal(values) {
|
|
385
386
|
return validateNumber(values.reduce(function (a, b) { return (a !== null && a !== void 0 ? a : 0) + (b !== null && b !== void 0 ? b : 0); }, 0));
|
|
386
387
|
}
|
|
388
|
+
function calculateKPG(kills, games) {
|
|
389
|
+
if (games === 0)
|
|
390
|
+
return validateNumber(kills !== null && kills !== void 0 ? kills : 0);
|
|
391
|
+
return roundTo(validateNumber((kills !== null && kills !== void 0 ? kills : 0) / (games !== null && games !== void 0 ? games : 0)), 2);
|
|
392
|
+
}
|
|
387
393
|
function roundTo(value, places) {
|
|
388
394
|
if (places === void 0) { places = 2; }
|
|
389
395
|
return validateNumber(Number(value.toFixed(places)));
|
|
@@ -2,6 +2,7 @@ export interface ProcessedPlayerResponse {
|
|
|
2
2
|
info: {
|
|
3
3
|
uuid: string;
|
|
4
4
|
xuid: string;
|
|
5
|
+
mcid: string;
|
|
5
6
|
username: string;
|
|
6
7
|
rank: string;
|
|
7
8
|
first_played: number;
|
|
@@ -13,26 +14,49 @@ export interface ProcessedPlayerResponse {
|
|
|
13
14
|
quest_count: number;
|
|
14
15
|
};
|
|
15
16
|
equipped_cosmetics: {
|
|
16
|
-
costume:
|
|
17
|
-
avatar:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
hub_title: string;
|
|
22
|
-
hat: string;
|
|
23
|
-
backbling: string;
|
|
17
|
+
costume: CosmeticResponseTypes[CosmeticType.Costume];
|
|
18
|
+
avatar: CosmeticResponseTypes[CosmeticType.Avatar];
|
|
19
|
+
hub_title: CosmeticResponseTypes[CosmeticType.HubTitle];
|
|
20
|
+
hat: CosmeticResponseTypes[CosmeticType.Hat];
|
|
21
|
+
backbling: CosmeticResponseTypes[CosmeticType.Backbling];
|
|
24
22
|
};
|
|
25
23
|
owned_cosmetics: {
|
|
26
|
-
costume:
|
|
27
|
-
avatar:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
costume: CosmeticResponseTypes[CosmeticType.Costume][];
|
|
25
|
+
avatar: CosmeticResponseTypes[CosmeticType.Avatar][];
|
|
26
|
+
hub_title: CosmeticResponseTypes[CosmeticType.HubTitle][];
|
|
27
|
+
hat: CosmeticResponseTypes[CosmeticType.Hat][];
|
|
28
|
+
pet: CosmeticResponseTypes[CosmeticType.Pet][];
|
|
29
|
+
mount: CosmeticResponseTypes[CosmeticType.Mount][];
|
|
30
|
+
backbling: CosmeticResponseTypes[CosmeticType.Backbling][];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare enum CosmeticType {
|
|
34
|
+
Costume = "costume",
|
|
35
|
+
Avatar = "avatar",
|
|
36
|
+
HubTitle = "hub_title",
|
|
37
|
+
Hat = "hat",
|
|
38
|
+
Pet = "pet",
|
|
39
|
+
Mount = "mount",
|
|
40
|
+
Backbling = "backbling"
|
|
41
|
+
}
|
|
42
|
+
export interface CosmeticResponseTypes {
|
|
43
|
+
[CosmeticType.Costume]: string;
|
|
44
|
+
[CosmeticType.Avatar]: {
|
|
45
|
+
name: string;
|
|
46
|
+
url: string;
|
|
47
|
+
};
|
|
48
|
+
[CosmeticType.HubTitle]: string;
|
|
49
|
+
[CosmeticType.Hat]: {
|
|
50
|
+
name: string;
|
|
51
|
+
icon: string;
|
|
52
|
+
rarity: string;
|
|
53
|
+
};
|
|
54
|
+
[CosmeticType.Pet]: string;
|
|
55
|
+
[CosmeticType.Mount]: string;
|
|
56
|
+
[CosmeticType.Backbling]: {
|
|
57
|
+
name: string;
|
|
58
|
+
icon: string;
|
|
59
|
+
rarity: string;
|
|
36
60
|
};
|
|
37
61
|
}
|
|
38
62
|
export default function processPlayerInfo(playerResponse: any): ProcessedPlayerResponse | null;
|
package/lib/processors/player.js
CHANGED
|
@@ -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)
|
|
@@ -9,6 +20,7 @@ function processPlayerInfo(playerResponse) {
|
|
|
9
20
|
var info = {
|
|
10
21
|
uuid: player.UUID,
|
|
11
22
|
xuid: player.xuid.toString(),
|
|
23
|
+
mcid: player.mcid,
|
|
12
24
|
username: player.username_cc,
|
|
13
25
|
rank: player.rank,
|
|
14
26
|
first_played: player.first_played,
|
package/lib/utils.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hive-bedrock-api",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "An API wrapper for the Hive Minecraft Bedrock Edition server.",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"types": "lib/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/CubeEdge-Studios/hive-bedrock.git"
|
|
10
|
-
},
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"author": "Cubeedge Studios",
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"hive-bedrock-data": "^
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsc"
|
|
18
|
-
},
|
|
19
|
-
"files": [
|
|
20
|
-
"lib/**/*"
|
|
21
|
-
],
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"ts-node": "^10.9.1",
|
|
24
|
-
"typescript": "^5.1.3"
|
|
25
|
-
}
|
|
26
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "hive-bedrock-api",
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"description": "An API wrapper for the Hive Minecraft Bedrock Edition server.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/CubeEdge-Studios/hive-bedrock.git"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "Cubeedge Studios",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"hive-bedrock-data": "^4.0.1"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"lib/**/*"
|
|
21
|
+
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"ts-node": "^10.9.1",
|
|
24
|
+
"typescript": "^5.1.3"
|
|
25
|
+
},
|
|
26
|
+
"gitHead": "f865bf66484826cd8d60885b5d5fe94469278015"
|
|
27
|
+
}
|