Useless else statements.

This commit is contained in:
GJ 2013-01-21 17:15:53 -05:00
parent 9512879cc7
commit 900623461a
2 changed files with 49 additions and 48 deletions

View File

@ -119,16 +119,18 @@ public enum SkillType {
} }
public static SkillType getSkill(String skillName) { public static SkillType getSkill(String skillName) {
if(skillName.equalsIgnoreCase("powerlevel") || skillName.equalsIgnoreCase("all")) { if (skillName.equalsIgnoreCase("powerlevel") || skillName.equalsIgnoreCase("all")) {
return SkillType.ALL; return SkillType.ALL;
} else { }
for(SkillType st : SkillType.values()) {
if(st.name().equalsIgnoreCase(skillName)) for (SkillType type : SkillType.values()) {
return st; if (type.name().equalsIgnoreCase(skillName)) {
} return type;
System.out.println("[DEBUG] Invalid mcMMO skill ("+skillName+")"); }
return null; }
}
System.out.println("[DEBUG] Invalid mcMMO skill (" + skillName + ")");
return null;
} }
/** /**

View File

@ -22,11 +22,11 @@ public class Leaderboard {
* Update the leader boards. * Update the leader boards.
*/ */
public static void updateLeaderboards() { public static void updateLeaderboards() {
if(System.currentTimeMillis() < lastUpdate + 600000) { 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 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 lastUpdate = System.currentTimeMillis(); //Log when the last update was run
//Initialize lists //Initialize lists
List<PlayerStat> mining, woodcutting, herbalism, excavation, acrobatics, repair, swords, axes, archery, unarmed, taming, fishing, powerlevel; List<PlayerStat> 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 * @return the requested leaderboard information
*/ */
public static String[] retrieveInfo(SkillType skillType, int pagenumber) { public static String[] retrieveInfo(SkillType skillType, int pagenumber) {
String[] info = new String[10]; String[] info = new String[10];
List<PlayerStat> statsList = playerStatHash.get(skillType); List<PlayerStat> statsList = playerStatHash.get(skillType);
if(statsList != null) { if(statsList != null) {
int destination; int destination;
//How many lines to skip through //How many lines to skip through
if (pagenumber == 1) { if (pagenumber == 1) {
destination = 0; destination = 0;
} }
@ -186,45 +186,44 @@ public class Leaderboard {
destination = (pagenumber * 10) - 9; destination = (pagenumber * 10) - 9;
} }
int currentPos = 0; int currentPos = 0;
for(PlayerStat ps : statsList) { for(PlayerStat ps : statsList) {
if(currentPos == 10) if(currentPos == 10)
break; break;
if(destination > 1) { if(destination > 1) {
destination--; destination--;
continue; continue;
} }
info[currentPos] = ps.name+":"+ps.statVal; info[currentPos] = ps.name+":"+ps.statVal;
currentPos++; currentPos++;
} }
} else { } 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; return info;
} }
public static int[] getPlayerRank(String playerName, SkillType skillType) { public static int[] getPlayerRank(String playerName, SkillType skillType) {
int currentPos = 1; int currentPos = 1;
List<PlayerStat> statsList = playerStatHash.get(skillType); List<PlayerStat> statsList = playerStatHash.get(skillType);
if(statsList != null) { if (statsList != null) {
for(PlayerStat ps : statsList) { for (PlayerStat stat : statsList) {
if(ps.name.equalsIgnoreCase(playerName)) { if (stat.name.equalsIgnoreCase(playerName)) {
return new int[] {currentPos, ps.statVal}; return new int[] {currentPos, stat.statVal};
} else { }
currentPos++;
continue;
}
}
return new int[] {0}; currentPos++;
} else { continue;
return new int[] {0}; }
return new int[] {0};
} }
return new int[] {0};
} }
private static class SkillComparator implements Comparator<PlayerStat> { private static class SkillComparator implements Comparator<PlayerStat> {