From b7bb3f4487cb449ce4fd73530e1060d520da39f2 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 24 Jan 2013 09:08:30 -0500 Subject: [PATCH] Don't include child skills in these loops. Fixes #577 --- .../nossr50/commands/mc/McrankCommand.java | 3 +++ .../gmail/nossr50/datatypes/McMMOPlayer.java | 2 +- .../gmail/nossr50/datatypes/PlayerProfile.java | 18 +++++++++++++++++- .../java/com/gmail/nossr50/skills/Skills.java | 2 +- .../com/gmail/nossr50/spout/SpoutStuff.java | 4 ++-- .../java/com/gmail/nossr50/util/Hardcore.java | 4 ++-- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McrankCommand.java index ce3c0b386..f6943c23e 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McrankCommand.java @@ -58,6 +58,9 @@ public class McrankCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName})); for (SkillType skillType : SkillType.values()) { int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType); + if (skillType.isChildSkill()) { + continue; + } if (skillType.equals(SkillType.ALL)) { continue; // We want the overall ranking to be at the bottom diff --git a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java index 120c772c1..f4c5dcd54 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java @@ -85,7 +85,7 @@ public class McMMOPlayer { public void addXPOverride(SkillType skillType, int xp) { if (skillType.equals(SkillType.ALL)) { for (SkillType type : SkillType.values()) { - if (type.equals(SkillType.ALL)) { + if (type.equals(SkillType.ALL) || type.isChildSkill()) { continue; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index e5481470a..71610a34f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -70,7 +70,7 @@ public class PlayerProfile { } for (SkillType skillType : SkillType.values()) { - if (skillType != SkillType.ALL) { + if (skillType != SkillType.ALL && !skillType.isChildSkill()) { skills.put(skillType, 0); skillsXp.put(skillType, 0); } @@ -945,6 +945,10 @@ public class PlayerProfile { public void resetSkill(SkillType skillType) { + if (skillType.isChildSkill()) { + return; + } + //do a single skilltype if (skillType != SkillType.ALL) skills.put(skillType, 0); @@ -1060,6 +1064,10 @@ public class PlayerProfile { * @param xp Amount of xp to remove */ public void removeXP(SkillType skillType, int xp) { + if (skillType.isChildSkill()) { + return; + } + if (skillType.equals(SkillType.ALL)) { for (SkillType skill : SkillType.values()) { if (skill.equals(SkillType.ALL)) { @@ -1082,6 +1090,10 @@ public class PlayerProfile { * @param newValue New level value for the skill */ public void modifySkill(SkillType skillType, int newValue) { + if (skillType.isChildSkill()) { + return; + } + if (skillType.equals(SkillType.ALL)) { for (SkillType skill : SkillType.values()) { if (skill.equals(SkillType.ALL)) { @@ -1106,6 +1118,10 @@ public class PlayerProfile { * @param levels Number of levels to add */ public void addLevels(SkillType skillType, int levels) { + if (skillType.isChildSkill()) { + return; + } + if (skillType.equals(SkillType.ALL)) { for (SkillType skill : SkillType.values()) { if (skill.equals(SkillType.ALL)) { diff --git a/src/main/java/com/gmail/nossr50/skills/Skills.java b/src/main/java/com/gmail/nossr50/skills/Skills.java index ba9a1a138..b06aa3c4e 100644 --- a/src/main/java/com/gmail/nossr50/skills/Skills.java +++ b/src/main/java/com/gmail/nossr50/skills/Skills.java @@ -256,7 +256,7 @@ public class Skills { public static void xpCheckAll(Player player, PlayerProfile profile) { for (SkillType skillType : SkillType.values()) { //Don't want to do anything with this one - if (skillType == SkillType.ALL) { + if (skillType == SkillType.ALL || skillType.isChildSkill()) { continue; } diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java b/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java index 14ef9c892..71b64e223 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java @@ -136,7 +136,7 @@ public class SpoutStuff { //Standard XP Icons for (SkillType y : SkillType.values()) { - if (y.equals(SkillType.ALL)) { + if (y.equals(SkillType.ALL) || y.isChildSkill()) { continue; } @@ -197,7 +197,7 @@ public class SpoutStuff { /* Standard XP Icons */ for (SkillType y : SkillType.values()) { - if (y.equals(SkillType.ALL)) { + if (y.equals(SkillType.ALL) || y.isChildSkill()) { continue; } diff --git a/src/main/java/com/gmail/nossr50/util/Hardcore.java b/src/main/java/com/gmail/nossr50/util/Hardcore.java index d239175fc..238b861dc 100644 --- a/src/main/java/com/gmail/nossr50/util/Hardcore.java +++ b/src/main/java/com/gmail/nossr50/util/Hardcore.java @@ -20,7 +20,7 @@ public abstract class Hardcore { int totalLost = 0; for (SkillType skillType : SkillType.values()) { - if (skillType.equals(SkillType.ALL)) { + if (skillType.equals(SkillType.ALL) || skillType.isChildSkill()) { continue; } @@ -52,7 +52,7 @@ public abstract class Hardcore { int totalStolen = 0; for (SkillType skillType : SkillType.values()) { - if (skillType.equals(SkillType.ALL)) { + if (skillType.equals(SkillType.ALL) || skillType.isChildSkill()) { continue; }