Part one of sql for mcRank

This commit is contained in:
t00thpick1 2013-01-15 18:35:21 -05:00
parent 96e2cfaad6
commit 5512bd7df6

View File

@ -1,13 +1,17 @@
package com.gmail.nossr50.commands.mc; package com.gmail.nossr50.commands.mc;
import java.util.Map;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
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.util.Database;
import com.gmail.nossr50.util.Leaderboard; import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
@ -26,14 +30,9 @@ public class McrankCommand implements CommandExecutor {
arg0.sendMessage(ChatColor.RED+"TARGET: "+ChatColor.WHITE+playerName); arg0.sendMessage(ChatColor.RED+"TARGET: "+ChatColor.WHITE+playerName);
if(Config.getInstance().getUseMySQL()) { if(Config.getInstance().getUseMySQL()) {
//MySQL Version sqlDisplay(arg0, playerName);
} else { } else {
for(SkillType skillType : SkillType.values()) { flatfileDisplayer(arg0, playerName);
if(skillType.equals(SkillType.ALL))
continue; //We want the overall ranking to be at the bottom
arg0.sendMessage(ChatColor.YELLOW+Misc.getCapitalized(skillType.name())+ChatColor.GREEN+" - "+ChatColor.GOLD+"Rank "+ChatColor.WHITE+"#"+ChatColor.GREEN+Leaderboard.getPlayerRank(playerName, skillType));
}
arg0.sendMessage(ChatColor.YELLOW+"Overall"+ChatColor.GREEN+" - "+ChatColor.GOLD+"Rank "+ChatColor.WHITE+"#"+ChatColor.GREEN+Leaderboard.getPlayerRank(playerName, SkillType.ALL));
} }
} else { } else {
@ -42,4 +41,26 @@ public class McrankCommand implements CommandExecutor {
return true; return true;
} }
public void flatfileDisplayer(CommandSender sender, String playerName) {
for (SkillType skillType : SkillType.values()) {
if (skillType.equals(SkillType.ALL))
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));
}
sender.sendMessage(ChatColor.YELLOW + "Overall" + ChatColor.GREEN + " - " + ChatColor.GOLD + "Rank " + ChatColor.WHITE + "#" + ChatColor.GREEN + Leaderboard.getPlayerRank(playerName, SkillType.ALL));
}
private void sqlDisplay(CommandSender sender, String playerName) {
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
Database database = mcMMO.getPlayerDatabase();
Map<String, Integer> skills = database.readSQLRank(playerName);
for (SkillType skillType : SkillType.values()) {
if (skillType.equals(SkillType.ALL))
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 + skills.get(skillType.name()));
}
sender.sendMessage(ChatColor.YELLOW + "Overall" + ChatColor.GREEN + " - " + ChatColor.GOLD + "Rank " + ChatColor.WHITE + "#" + ChatColor.GREEN + skills.get("all"));
}
} }