mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
mcrank FFS output is now consistent with SQL
This commit is contained in:
parent
957605d46b
commit
fd4f0f4096
@ -9,9 +9,11 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.mcRankAsync;
|
import com.gmail.nossr50.runnables.mcRankAsync;
|
||||||
import com.gmail.nossr50.util.Leaderboard;
|
import com.gmail.nossr50.util.Leaderboard;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.Skills;
|
||||||
|
|
||||||
public class McrankCommand implements CommandExecutor {
|
public class McrankCommand implements CommandExecutor {
|
||||||
|
|
||||||
@ -51,10 +53,28 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
|
|
||||||
public void flatfileDisplay(CommandSender sender, String playerName) {
|
public void flatfileDisplay(CommandSender sender, String playerName) {
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
|
||||||
|
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
|
||||||
|
|
||||||
if (skillType.equals(SkillType.ALL))
|
if (skillType.equals(SkillType.ALL))
|
||||||
continue; // We want the overall ranking to be at the bottom
|
continue; // We want the overall ranking to be at the bottom
|
||||||
sender.sendMessage(ChatColor.YELLOW + Misc.getCapitalized(skillType.name()) + ChatColor.GREEN + " - " + ChatColor.GOLD + "Rank " + ChatColor.WHITE + "#" + ChatColor.GREEN + Leaderboard.getPlayerRank(playerName, skillType));
|
|
||||||
|
if (rankInts[1] == 0) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), String.valueOf(rankInts[0])} ));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Show the powerlevel ranking
|
||||||
|
int[] rankInts = Leaderboard.getPlayerRank(playerName, SkillType.ALL);
|
||||||
|
|
||||||
|
if (rankInts[1] == 0) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(SkillType.ALL), LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(SkillType.ALL), String.valueOf(rankInts[0])} ));
|
||||||
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Overall" + ChatColor.GREEN + " - " + ChatColor.GOLD + "Rank " + ChatColor.WHITE + "#" + ChatColor.GREEN + Leaderboard.getPlayerRank(playerName, SkillType.ALL));
|
sender.sendMessage(ChatColor.YELLOW + "Overall" + ChatColor.GREEN + " - " + ChatColor.GOLD + "Rank " + ChatColor.WHITE + "#" + ChatColor.GREEN + Leaderboard.getPlayerRank(playerName, SkillType.ALL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,23 +200,23 @@ public class Leaderboard {
|
|||||||
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 ps : statsList) {
|
||||||
if(ps.name.equalsIgnoreCase(playerName)) {
|
if(ps.name.equalsIgnoreCase(playerName)) {
|
||||||
return currentPos;
|
return new int[] {currentPos, ps.statVal};
|
||||||
} else {
|
} else {
|
||||||
currentPos++;
|
currentPos++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return new int[] {0};
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return new int[] {0};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user