diff --git a/index.d.ts b/index.d.ts index 1b83acbc7..c050cadbb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -503,6 +503,7 @@ export interface Experience { level: number points: number progress: number + getXpPoints: () => number } export interface PhysicsOptions { diff --git a/lib/plugins/experience.js b/lib/plugins/experience.js index 1c8334ac3..e31e75537 100644 --- a/lib/plugins/experience.js +++ b/lib/plugins/experience.js @@ -12,4 +12,12 @@ function inject (bot) { bot.experience.progress = packet.experienceBar bot.emit('experience') }) + + bot.experience.getXpPoints = function () { + const levelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level) + const incrementedLevelToXpPoints = bot.experience.convertLevelsToXpPoints(bot.experience.level + 1) + const xpForNextLevel = incrementedLevelToXpPoints - levelToXpPoints + + return Math.floor(levelToXpPoints + bot.experience.progress * xpForNextLevel) + } }