mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Formatting, and reminding myself to come back and fix this even further.
This commit is contained in:
parent
2a4fe4aa48
commit
1a888d3116
@ -6,6 +6,7 @@ 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.commands.CommandHelper;
|
||||||
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.locale.LocaleLoader;
|
||||||
@ -17,30 +18,36 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(!Config.getInstance().getUseMySQL())
|
//TODO: Better input handling, add usage string
|
||||||
Leaderboard.updateLeaderboards(); //Make sure the information is up to date
|
|
||||||
|
|
||||||
if(sender instanceof Player) {
|
if (!Config.getInstance().getUseMySQL()) {
|
||||||
Player player = (Player) sender;
|
Leaderboard.updateLeaderboards(); //Make sure the information is up to date
|
||||||
String playerName;
|
}
|
||||||
switch(args.length){
|
|
||||||
case 0:
|
|
||||||
playerName = player.getName();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
playerName = args[0];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(Config.getInstance().getUseMySQL()) {
|
|
||||||
sqlDisplay(sender, playerName);
|
|
||||||
} else {
|
|
||||||
flatfileDisplay(sender, playerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
sender.sendMessage("Command currently not supported for console.");
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
String playerName;
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
playerName = player.getName();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
playerName = args[0];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
|
sqlDisplay(sender, playerName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
flatfileDisplay(sender, playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -50,15 +57,16 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName}));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName}));
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
|
||||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
|
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
|
||||||
|
}
|
||||||
|
|
||||||
if (rankInts[1] == 0) {
|
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
|
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 {
|
}
|
||||||
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), String.valueOf(rankInts[0])} ));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), String.valueOf(rankInts[0])} ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,12 +76,12 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (rankInts[1] == 0) {
|
if (rankInts[1] == 0) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", new Object[] {LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", new Object[] {LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", new Object[] {String.valueOf(rankInts[0])} ));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", new Object[] {String.valueOf(rankInts[0])} ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getPluginManager().getPlugin("mcMMO"), new McRankAsync(playerName, sender));
|
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getPluginManager().getPlugin("mcMMO"), new McRankAsync(playerName, sender));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user