Added 'rpg admin level take' command

This commit is contained in:
ASangarin 2020-11-01 15:44:54 +01:00
parent 06b3aee9bf
commit 7b16bced13
3 changed files with 12 additions and 0 deletions

View File

@ -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);
}

View File

@ -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)

View File

@ -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 {