diff --git a/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java b/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java index 1a151cdb..6f7f564a 100644 --- a/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java +++ b/src/main/java/net/Indyuce/mmocore/api/experience/PlayerProfessions.java @@ -99,6 +99,11 @@ public class PlayerProfessions { level.put(profession.getId(), value); } + public void takeLevels(Profession profession, int value) { + int current = level.getOrDefault(profession.getId(), 1); + level.put(profession.getId(), Math.max(1, current - value)); + } + public void setExperience(Profession profession, int value) { exp.put(profession.getId(), value); } 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 5ab5db89..2bf111e6 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -240,6 +240,11 @@ public class PlayerData extends OfflinePlayerData { getStats().updateStats(); } + public void takeLevels(int value) { + this.level = Math.max(1, level - value); + getStats().updateStats(); + } + public void giveLevels(int value, EXPSource source) { int total = 0; while (value-- > 0) diff --git a/src/main/java/net/Indyuce/mmocore/command/rpg/admin/LevelCommandTreeNode.java b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/LevelCommandTreeNode.java index 0e6fa5aa..07dd39aa 100644 --- a/src/main/java/net/Indyuce/mmocore/command/rpg/admin/LevelCommandTreeNode.java +++ b/src/main/java/net/Indyuce/mmocore/command/rpg/admin/LevelCommandTreeNode.java @@ -24,6 +24,8 @@ public class LevelCommandTreeNode extends CommandTreeNode { (professions, profession, value) -> professions.setLevel(profession, value))); addChild(new ActionCommandTreeNode(this, "give", (data, value) -> data.giveLevels(value, EXPSource.COMMAND), (professions, profession, value) -> professions.giveLevels(profession, value, EXPSource.COMMAND))); + addChild(new ActionCommandTreeNode(this, "take", (data, value) -> data.takeLevels(value), + (professions, profession, value) -> professions.takeLevels(profession, value))); } public class ActionCommandTreeNode extends CommandTreeNode {