From 900623461a527fe1bc52bd25223980eeb1bbd74d Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 21 Jan 2013 17:15:53 -0500 Subject: [PATCH] Useless else statements. --- .../gmail/nossr50/datatypes/SkillType.java | 22 +++--- .../com/gmail/nossr50/util/Leaderboard.java | 75 +++++++++---------- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/datatypes/SkillType.java b/src/main/java/com/gmail/nossr50/datatypes/SkillType.java index df84ea4ff..ccfea7dea 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/SkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/SkillType.java @@ -119,16 +119,18 @@ public enum SkillType { } public static SkillType getSkill(String skillName) { - if(skillName.equalsIgnoreCase("powerlevel") || skillName.equalsIgnoreCase("all")) { - return SkillType.ALL; - } else { - for(SkillType st : SkillType.values()) { - if(st.name().equalsIgnoreCase(skillName)) - return st; - } - System.out.println("[DEBUG] Invalid mcMMO skill ("+skillName+")"); - return null; - } + if (skillName.equalsIgnoreCase("powerlevel") || skillName.equalsIgnoreCase("all")) { + return SkillType.ALL; + } + + for (SkillType type : SkillType.values()) { + if (type.name().equalsIgnoreCase(skillName)) { + return type; + } + } + + System.out.println("[DEBUG] Invalid mcMMO skill (" + skillName + ")"); + return null; } /** diff --git a/src/main/java/com/gmail/nossr50/util/Leaderboard.java b/src/main/java/com/gmail/nossr50/util/Leaderboard.java index 84689cde1..e200db2f8 100644 --- a/src/main/java/com/gmail/nossr50/util/Leaderboard.java +++ b/src/main/java/com/gmail/nossr50/util/Leaderboard.java @@ -22,12 +22,12 @@ public class Leaderboard { * Update the leader boards. */ public static void updateLeaderboards() { - if(System.currentTimeMillis() < lastUpdate + 600000) { - return; //Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently - } - - lastUpdate = System.currentTimeMillis(); //Log when the last update was run - + if(System.currentTimeMillis() < lastUpdate + 600000) { + return; //Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently + } + + lastUpdate = System.currentTimeMillis(); //Log when the last update was run + //Initialize lists List mining, woodcutting, herbalism, excavation, acrobatics, repair, swords, axes, archery, unarmed, taming, fishing, powerlevel; @@ -171,14 +171,14 @@ public class Leaderboard { * @return the requested leaderboard information */ public static String[] retrieveInfo(SkillType skillType, int pagenumber) { - String[] info = new String[10]; + String[] info = new String[10]; List statsList = playerStatHash.get(skillType); if(statsList != null) { - int destination; - - //How many lines to skip through + int destination; + + //How many lines to skip through if (pagenumber == 1) { destination = 0; } @@ -186,45 +186,44 @@ public class Leaderboard { destination = (pagenumber * 10) - 9; } - int currentPos = 0; + int currentPos = 0; + + for(PlayerStat ps : statsList) { + if(currentPos == 10) + break; + if(destination > 1) { + destination--; + continue; + } + + info[currentPos] = ps.name+":"+ps.statVal; + currentPos++; + } - for(PlayerStat ps : statsList) { - if(currentPos == 10) - break; - if(destination > 1) { - destination--; - continue; - } - - info[currentPos] = ps.name+":"+ps.statVal; - currentPos++; - } - } else { - info[0] = "DummyPlayer:0"; //Coming up with a better solution soon... + info[0] = "DummyPlayer:0"; //Coming up with a better solution soon... } return info; } public static int[] getPlayerRank(String playerName, SkillType skillType) { - int currentPos = 1; + int currentPos = 1; List statsList = playerStatHash.get(skillType); - if(statsList != null) { - for(PlayerStat ps : statsList) { - if(ps.name.equalsIgnoreCase(playerName)) { - return new int[] {currentPos, ps.statVal}; - } else { - currentPos++; - continue; - } - } - - return new int[] {0}; - } else { - return new int[] {0}; + if (statsList != null) { + for (PlayerStat stat : statsList) { + if (stat.name.equalsIgnoreCase(playerName)) { + return new int[] {currentPos, stat.statVal}; + } + + currentPos++; + continue; + } + return new int[] {0}; } + + return new int[] {0}; } private static class SkillComparator implements Comparator {