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

48 lines
1.5 KiB
Java
Raw Normal View History

2013-03-21 20:46:23 +01:00
package com.gmail.nossr50.runnables.commands;
import java.util.List;
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.datatypes.database.PlayerStat;
2013-03-21 20:46:23 +01:00
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
public class MctopCommandDisplayTask extends BukkitRunnable {
private List<PlayerStat> userStats;
2013-03-21 20:46:23 +01:00
private CommandSender sender;
private String skill;
2013-03-21 20:46:23 +01:00
private int page;
public MctopCommandDisplayTask(List<PlayerStat> userStats, int page, String skill, CommandSender sender) {
this.userStats = userStats;
2013-03-21 20:46:23 +01:00
this.page = page;
this.skill = skill;
2013-03-21 20:46:23 +01:00
this.sender = sender;
}
@Override
public void run() {
if (skill.equalsIgnoreCase("all")) {
2013-03-21 20:46:23 +01:00
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
2013-03-21 20:46:23 +01:00
}
int place = (page * 10) - 9;
for (PlayerStat 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.name + " - " + ChatColor.WHITE + stat.statVal);
2013-03-21 20:46:23 +01:00
place++;
}
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
}
}