mcMMO/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java

48 lines
1.6 KiB
Java
Raw Normal View History

2013-03-21 20:46:23 +01:00
package com.gmail.nossr50.runnables.commands;
import java.util.ArrayList;
import java.util.Collection;
2013-03-21 20:46:23 +01:00
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
public class MctopCommandDisplayTask extends BukkitRunnable {
private Collection<ArrayList<String>> userStats;
2013-03-21 20:46:23 +01:00
private CommandSender sender;
private String query;
private int page;
public MctopCommandDisplayTask(Collection<ArrayList<String>> userStats, int page, String query, CommandSender sender) {
this.userStats = userStats;
2013-03-21 20:46:23 +01:00
this.page = page;
this.query = query;
this.sender = sender;
}
@Override
public void run() {
if (query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query)));
}
int place = (page * 10) - 9;
for (ArrayList<String> stat : userStats) {
String digit = (place < 10) ? "0" : "" + String.valueOf(place);
2013-03-21 20:46:23 +01:00
// Format: 1. Playername - skill value
sender.sendMessage(digit + ". " + ChatColor.GREEN + stat.get(1) + " - " + ChatColor.WHITE + stat.get(0));
2013-03-21 20:46:23 +01:00
place++;
}
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
}
}