We've got these functions, might as well use them.

This commit is contained in:
GJ 2013-05-21 10:02:09 -04:00
parent a2f80569e3
commit 0c52b3016c
10 changed files with 47 additions and 89 deletions

View File

@ -506,11 +506,7 @@ public final class ExperienceAPI {
int powerLevel = 0;
PlayerProfile profile = getOfflineProfile(playerName);
for (SkillType type : SkillType.values()) {
if (type.isChildSkill()) {
continue;
}
for (SkillType type : SkillType.nonChildSkills()) {
powerLevel += profile.getSkillLevel(type);
}

View File

@ -294,11 +294,7 @@ public final class FlatfileDatabaseManager {
Map<String, Integer> skills = new HashMap<String, Integer>();
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
}

View File

@ -415,11 +415,7 @@ public final class SQLDatabaseManager {
if (checkConnected()) {
try {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
String skillName = skillType.name().toLowerCase();
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +

View File

@ -441,11 +441,7 @@ public class McMMOPlayer {
public int getPowerLevel() {
int powerLevel = 0;
for (SkillType type : SkillType.values()) {
if (type.isChildSkill()) {
continue;
}
for (SkillType type : SkillType.nonChildSkills()) {
if (Permissions.skillEnabled(player, type)) {
powerLevel += profile.getSkillLevel(type);
}

View File

@ -49,11 +49,7 @@ public class PlayerProfile {
skillsDATS.put(abilityType, 0);
}
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
skills.put(skillType, 0);
skillsXp.put(skillType, 0F);
}

View File

@ -31,8 +31,8 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || (player != null && !Permissions.skillEnabled(player, skill))) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (player != null && !Permissions.skillEnabled(player, skill)) {
continue;
}

View File

@ -19,8 +19,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
protected void loadKeys() {
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
for (SkillType skill : SkillType.childSkills()) {
plugin.debug("Finding parents of " + skill.name());
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
@ -29,7 +28,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
for (String name : parentNames) {
try {
SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase());
SkillType parentSkill = SkillType.valueOf(name.toUpperCase());
FamilyTree.enforceNotChildSkill(parentSkill);
parentSkills.add(parentSkill);
}
@ -57,7 +56,6 @@ public class ChildConfig extends AutoUpdateConfigLoader {
FamilyTree.registerParent(skill, parentSkill);
}
}
}
FamilyTree.closeRegistration();
}

View File

@ -21,11 +21,7 @@ public final class HardcoreManager {
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
int totalLost = 0;
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
if (playerSkillLevel <= 0) {
@ -52,11 +48,7 @@ public final class HardcoreManager {
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
int totalStolen = 0;
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
int victimSkillLevel = victimProfile.getSkillLevel(skillType);

View File

@ -182,8 +182,8 @@ public class ScoreboardManager {
PlayerProfile profile = mcMMOPlayer.getProfile();
Server server = mcMMO.p.getServer();
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(player, skill)) {
continue;
}
@ -201,8 +201,8 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(playerName) : FlatfileDatabaseManager.getPlayerRanks(playerName);
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(player, skill)) {
continue;
}
@ -228,11 +228,7 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(targetName) : FlatfileDatabaseManager.getPlayerRanks(targetName);
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
rank = skills.get(skill.name());
if (rank != null) {
@ -257,8 +253,8 @@ public class ScoreboardManager {
int powerLevel = 0;
int skillLevel;
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(target, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(target, skill)) {
continue;
}
@ -277,11 +273,7 @@ public class ScoreboardManager {
int powerLevel = 0;
int skillLevel;
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
skillLevel = targetProfile.getSkillLevel(skill);
objective.getScore(server.getOfflinePlayer(SkillUtils.getSkillName(skill))).setScore(skillLevel);
powerLevel += skillLevel;

View File

@ -204,11 +204,7 @@ public class SpoutUtils {
}
// Standard XP Icons
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
String skillName = StringUtils.getCapitalized(skillType.toString());
files.add(writeFile(skillName + ".png", hudStandardDirectory));