Skip to content

Commit 60292e9

Browse files
committed
feat(grabber): add crafatar host config
1 parent 66eee76 commit 60292e9

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

config.example.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ web:
55
homepage: https://minecraft.example.com # Your homepage
66

77
render:
8+
crafatar: https://crafatar.com # crafatar service host, required
89
level: data/level.dat # file path here, required
910
playerdata: data/playerdata # directory path here, required
1011
stats: data/stats # directory path here, required

utils.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,28 +218,28 @@ module.exports = class Utils {
218218
return body
219219
}
220220

221-
static getPlayerAssets (uuid, playerpath) {
221+
async getPlayerAssets (uuid, playerpath) {
222222
try {
223223
fs.ensureDirSync(playerpath)
224224
} catch (error) {
225225
throw new Error(error)
226226
}
227227

228-
const apiPrefixAvatar = 'https://crafatar.com/avatars/'
229-
const apiPrefixBody = 'https://crafatar.com/renders/body/'
230-
const apiPrefixSkin = 'https://crafatar.com/skins/'
228+
const apiPrefixAvatar = `${this.config.render.crafatar}/avatars/`
229+
const apiPrefixBody = `${this.config.render.crafatar}/renders/body/`
230+
const apiPrefixSkin = `${this.config.render.crafatar}/skins/`
231231

232232
const slim = `&default=MHF_${defaultSkin(uuid)}`
233233

234-
download(
234+
await download(
235235
`${apiPrefixAvatar}${uuid}?size=64&overlay${slim}`,
236236
path.join(playerpath, 'avatar.png'),
237237
)
238-
download(
238+
await download(
239239
`${apiPrefixBody}${uuid}?size=128&overlay${slim}`,
240240
path.join(playerpath, 'body.png'),
241241
)
242-
download(
242+
await download(
243243
`${apiPrefixSkin}${uuid}?${slim}`,
244244
path.join(playerpath, 'skin.png'),
245245
)
@@ -261,7 +261,7 @@ module.exports = class Utils {
261261
return data
262262
} else if (data && data.stats && data.data) {
263263
try {
264-
await Utils.getPlayerAssets(uuid.replace(/-/g, ''), playerpath)
264+
await this.getPlayerAssets(uuid.replace(/-/g, ''), playerpath)
265265
} catch (error) {
266266
logger.PlayerData.error('ASSETS', error)
267267
}

0 commit comments

Comments
 (0)