瀏覽代碼

Fixed bug where /addxp was setting instead of adding experience

Fixes #898
TfT_02 12 年之前
父節點
當前提交
fc8ad40b00

+ 1 - 0
Changelog.txt

@@ -9,6 +9,7 @@ Key:
 
 
 Version 1.4.05-dev
 Version 1.4.05-dev
  + Added option to allow refreshing of chunks after block-breaking abilities. (Disabled by default)
  + 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
 Version 1.4.04
  + Added functions to ExperienceAPI for use with offline players
  + Added functions to ExperienceAPI for use with offline players

+ 1 - 1
src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java

@@ -24,7 +24,7 @@ public class AddxpCommand extends ExperienceCommand {
             mcMMOPlayer.applyXpGain(skill, value);
             mcMMOPlayer.applyXpGain(skill, value);
         }
         }
         else {
         else {
-            profile.setSkillXpLevel(skill, value);
+            profile.addExperience(skill, value);
         }
         }
     }
     }
 
 

+ 14 - 0
src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java

@@ -666,6 +666,20 @@ public class PlayerProfile {
         skillsXp.put(skillType, 0);
         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.
      * Get the amount of Xp remaining before the next level.
      *
      *