From fc8ad40b00fa24262bceffb0a803dcc6cb6ea131 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 30 Mar 2013 10:50:05 +0100 Subject: [PATCH] Fixed bug where /addxp was setting instead of adding experience Fixes #898 --- Changelog.txt | 1 + .../nossr50/commands/experience/AddxpCommand.java | 2 +- .../nossr50/datatypes/player/PlayerProfile.java | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 95792ea5d..c38862c4f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,6 +9,7 @@ Key: Version 1.4.05-dev + Added option to allow refreshing of chunks after block-breaking abilities. (Disabled by default) + = Fixed bug where /addxp was setting instead of adding experience Version 1.4.04 + Added functions to ExperienceAPI for use with offline players diff --git a/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java index 806a25b64..1f5568d63 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java @@ -24,7 +24,7 @@ public class AddxpCommand extends ExperienceCommand { mcMMOPlayer.applyXpGain(skill, value); } else { - profile.setSkillXpLevel(skill, value); + profile.addExperience(skill, value); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index f227e2de3..31ef669c1 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -666,6 +666,20 @@ public class PlayerProfile { skillsXp.put(skillType, 0); } + /** + * Add Experience to a skill. + * + * @param skillType Type of skill to add experience to + * @param experience Number of experience to add + */ + public void addExperience(SkillType skillType, int experience) { + if (skillType.isChildSkill()) { + return; + } + + skillsXp.put(skillType, skillsXp.get(skillType) + experience); + } + /** * Get the amount of Xp remaining before the next level. *