aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md8
-rw-r--r--package-lock.json14
-rw-r--r--package.json2
-rw-r--r--src/cleaners/player.ts5
-rw-r--r--src/cleaners/skyblock/claimed.ts43
-rw-r--r--src/hypixelCached.ts3
-rw-r--r--src/util.ts5
7 files changed, 54 insertions, 26 deletions
diff --git a/README.md b/README.md
index 0e3216d..59937b2 100644
--- a/README.md
+++ b/README.md
@@ -22,3 +22,11 @@ If you (this is really just here for myself so I don't forget) are adding a new
- Use snake_case for values.
- Prefer arrays over dictionaries when the keys aren't static. For example `[ { name: "asdf", value: "dsfasg" } ]` rather than `{ "asdf": "dsfasg" }`.
- Dates are done with milliseconds since epoch
+- Fields that contain a snake_case ID should be called `id`. At the moment some of them are called `name`, this will be changed soon.
+
+## Development
+
+First, install the dependencies with `npm i`.
+Then to run it, do `tsc -w` in one terminal, `npx nodemon build` in another. This makes it automatically restart when you make a change.
+If you don't like it auto restarting, then just do `node build` instead of `npx nodemon build`.
+
diff --git a/package-lock.json b/package-lock.json
index ce5fa4f..097d534 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,7 +18,7 @@
"prismarine-nbt": "github:PrismarineJS/prismarine-nbt",
"prom-client": "^14.0.1",
"queue-promise": "^2.2.1",
- "typed-hypixel-api": "^0.6.0",
+ "typed-hypixel-api": "^1.1.0",
"uuid": "^8.3.2"
},
"devDependencies": {
@@ -2734,9 +2734,9 @@
}
},
"node_modules/typed-hypixel-api": {
- "version": "0.6.0",
- "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.6.0.tgz",
- "integrity": "sha512-wvv23ZfWTbGx4n+aM6QakDaqjFiLOz2Bdk1NtlIqDPW6uL5PnpcXUFnwBD81++wcXxmskxMjnUlX+rzD6tbRSg==",
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-1.1.0.tgz",
+ "integrity": "sha512-fWUKBtSZm430JffQ6jXCEZ4ec6a+CKZttnVXt1p9KBQNkmBH9SQDIDkXm+m3eoeadpx0rbaXXg3jXSS88TYfEw==",
"dependencies": {
"typescript": "^4.6.3",
"undici": "^4.16.0"
@@ -5070,9 +5070,9 @@
}
},
"typed-hypixel-api": {
- "version": "0.6.0",
- "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.6.0.tgz",
- "integrity": "sha512-wvv23ZfWTbGx4n+aM6QakDaqjFiLOz2Bdk1NtlIqDPW6uL5PnpcXUFnwBD81++wcXxmskxMjnUlX+rzD6tbRSg==",
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-1.1.0.tgz",
+ "integrity": "sha512-fWUKBtSZm430JffQ6jXCEZ4ec6a+CKZttnVXt1p9KBQNkmBH9SQDIDkXm+m3eoeadpx0rbaXXg3jXSS88TYfEw==",
"requires": {
"typescript": "^4.6.3",
"undici": "^4.16.0"
diff --git a/package.json b/package.json
index 26129ea..abf83bf 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
"prismarine-nbt": "github:PrismarineJS/prismarine-nbt",
"prom-client": "^14.0.1",
"queue-promise": "^2.2.1",
- "typed-hypixel-api": "^0.6.0",
+ "typed-hypixel-api": "^1.1.0",
"uuid": "^8.3.2"
},
"devDependencies": {
diff --git a/src/cleaners/player.ts b/src/cleaners/player.ts
index f2df07d..2d819e9 100644
--- a/src/cleaners/player.ts
+++ b/src/cleaners/player.ts
@@ -12,7 +12,12 @@ export interface CleanBasicPlayer {
}
export interface ClaimedSkyBlockItem {
+ /**
+ * name is kept for backwards compatibility, it will be changed to a more
+ * human readable name later
+ */
name: string
+ id: string
timestamp: number
}
diff --git a/src/cleaners/skyblock/claimed.ts b/src/cleaners/skyblock/claimed.ts
index 0873af9..1be0e17 100644
--- a/src/cleaners/skyblock/claimed.ts
+++ b/src/cleaners/skyblock/claimed.ts
@@ -1,49 +1,64 @@
-import { HypixelPlayerStatsSkyBlockProfiles } from '../../hypixelApi.js'
-import {
- CleanBasicProfile,
- CleanFullProfile,
- cleanSkyblockProfileResponse
-} from './profile.js'
import typedHypixelApi from 'typed-hypixel-api'
import { ClaimedSkyBlockItem } from '../player.js'
export function cleanPlayerSkyblockClaimed(data: typedHypixelApi.PlayerDataResponse['player']): ClaimedSkyBlockItem[] {
const claimedItems: ClaimedSkyBlockItem[] = []
+ // `name` is kept for backwards compatibility, it will be changed to a
+ // more human readable name later!
+
if (data.claimed_potato_talisman)
claimedItems.push({
+ id: 'potato_talisman',
name: 'potato_talisman',
timestamp: data.claimed_potato_talisman
})
-
- const centuryCakes = Object.keys(data).filter((key) => key.startsWith('claimed_century_cake'))
- for (const centuryCake of centuryCakes) {
- const centuryCakeYear = centuryCake === 'claimed_century_cake' ? '100' : centuryCake.slice('claimed_century_cake'.length)
+ if (data.claim_potato_war_crown)
claimedItems.push({
- name: `year_${centuryCakeYear}_century_cake`,
- timestamp: data[centuryCake]
+ id: 'potato_crown',
+ name: 'potato_crown',
+ timestamp: data.claim_potato_war_crown
+ })
+ if (data.claimed_potato_basket)
+ claimedItems.push({
+ id: 'potato_basket',
+ name: 'potato_basket',
+ timestamp: data.claimed_potato_basket
})
- }
-
if (data.claimed_year143_cake)
claimedItems.push({
+ id: 'year_143_cake',
name: 'year_143_cake',
timestamp: data.claimed_year143_cake
})
if (data.skyblock_free_cookie)
claimedItems.push({
+ id: 'free_booster_cookie',
name: 'free_booster_cookie',
timestamp: data.skyblock_free_cookie
})
+ const centuryCakes = Object.keys(data).filter((key) => key.startsWith('claimed_century_cake'))
+ for (const centuryCake of centuryCakes) {
+ const centuryCakeYear = centuryCake === 'claimed_century_cake' ? '100' : centuryCake.slice('claimed_century_cake'.length)
+ claimedItems.push({
+ id: `year_${centuryCakeYear}_century_cake`,
+ name: `year_${centuryCakeYear}_century_cake`,
+ timestamp: data[centuryCake]
+ })
+ }
+
const scorpiusBribes = Object.keys(data).filter((key) => key.startsWith('scorpius_bribe_'))
for (const bribe of scorpiusBribes) {
const bribeYear = bribe.slice('scorpius_bribe_'.length)
claimedItems.push({
+ id: `year_${bribeYear}_scorpius_bribe`,
name: `year_${bribeYear}_scorpius_bribe`,
timestamp: data[bribe]
})
}
+ claimedItems.sort((a, b) => a.timestamp - b.timestamp)
+
return claimedItems
}
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts
index aaea7c5..d92ba75 100644
--- a/src/hypixelCached.ts
+++ b/src/hypixelCached.ts
@@ -205,8 +205,9 @@ export async function fetchBasicPlayer(user: string, includeClaimed: boolean = t
if (basicPlayerCache.has(playerUuid)) {
const player = basicPlayerCache.get(playerUuid)!
- if (!includeClaimed)
+ if (!includeClaimed) {
delete player.claimed
+ }
return player
}
diff --git a/src/util.ts b/src/util.ts
index 4d40cc0..91f202d 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -1,6 +1,5 @@
-/**
- * Random utility functions that are not related to Hypixel
- */
+// Random utility functions that are not related to Hypixel
+
export function undashUuid(uuid: string): string {
return uuid.replace(/-/g, '').toLowerCase()