Browse Source

Fix `/addlevels all` and `/skillreset all` commands

Fixes #1675
TfT_02 11 years ago
parent
commit
65aa05a660

+ 1 - 0
Changelog.txt

@@ -25,6 +25,7 @@ Version 1.4.08-dev
  = Fixed bug where disabling hardcore mode for specific skills didn't work
  = Fixed bug which caused the backup cleanup to delete old backups while it should have kept those
  = Fixed bug where party chat broke if the display name contained special characters
+ = Fixed bug where `/addlevels all` and `/skillreset all` didn't work
  ! Updated localization files
  ! Changed AxesCritical to CriticalHit in config file
  ! Changed several secondary ability permissions(deprecated versions still exist)

+ 13 - 5
src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java

@@ -24,6 +24,8 @@ import com.google.common.collect.ImmutableList;
 public abstract class ExperienceCommand implements TabExecutor {
     @Override
     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+        SkillType skill;
+
         switch (args.length) {
             case 2:
                 if (CommandUtils.noConsoleUsage(sender)) {
@@ -39,7 +41,13 @@ public abstract class ExperienceCommand implements TabExecutor {
                     return true;
                 }
 
-                editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0]), Integer.parseInt(args[1]));
+                skill = SkillType.getSkill(args[0]);
+
+                if (args[1].equalsIgnoreCase("all")) {
+                    skill = null;
+                }
+
+                editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
                 return true;
 
             case 3:
@@ -52,12 +60,12 @@ public abstract class ExperienceCommand implements TabExecutor {
                     return true;
                 }
 
-                SkillType skill;
+                skill = SkillType.getSkill(args[1]);
+
                 if (args[1].equalsIgnoreCase("all")) {
                     skill = null;
-                } else {
-                    skill = SkillType.getSkill(args[1]);
                 }
+
                 int value = Integer.parseInt(args[2]);
 
                 String playerName = Misc.getMatchedPlayerName(args[0]);
@@ -123,7 +131,7 @@ public abstract class ExperienceCommand implements TabExecutor {
 
     protected void editValues(Player player, PlayerProfile profile, SkillType skill, int value) {
         if (skill == null) {
-            for (SkillType skillType : SkillType.values()) {
+            for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
                 handleCommand(player, profile, skillType, value);
             }
 

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

@@ -152,7 +152,7 @@ public class SkillresetCommand implements TabExecutor {
 
     protected void editValues(Player player, PlayerProfile profile, SkillType skill) {
         if (skill == null) {
-            for (SkillType skillType : SkillType.values()) {
+            for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
                 handleCommand(player, profile, skillType);
             }