From f6396e64067e14c4599dc323c701a62b5d0581d4 Mon Sep 17 00:00:00 2001 From: Indyuce Date: Sun, 1 Sep 2019 14:48:36 +0200 Subject: [PATCH] added give levels methods --- .../java/net/Indyuce/mmocore/api/player/PlayerData.java | 7 +++++++ .../java/net/Indyuce/mmocore/api/player/Professions.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index eae23e31..b6129e38 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -305,6 +305,13 @@ public class PlayerData { getStats().updateAll(); } + public void giveLevels(int value) { + int total = 0; + while (value-- > 0) + total += MMOCore.plugin.configManager.getNeededExperience(getLevel() + value + 1); + giveExperience(total); + } + public void setExperience(int value) { experience = Math.max(0, value); refreshVanillaExp(MMOCore.plugin.configManager.getNeededExperience(getLevel() + 1)); diff --git a/src/main/java/net/Indyuce/mmocore/api/player/Professions.java b/src/main/java/net/Indyuce/mmocore/api/player/Professions.java index 1ebe4b2b..d9218608 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/Professions.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/Professions.java @@ -70,6 +70,13 @@ public class Professions { level.put(profession.getId(), value); } + public void giveLevels(Profession profession, int value) { + int total = 0, level = getLevel(profession); + while (value-- > 0) + total += MMOCore.plugin.configManager.getNeededExperience(level + value + 1); + giveExperience(profession, total); + } + public void giveExperience(Profession profession, int value) { giveExperience(profession, value, null); }