2013-03-21 20:46:23 +01:00
|
|
|
package com.gmail.nossr50.runnables.commands;
|
|
|
|
|
2015-12-12 05:30:21 +01:00
|
|
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
2013-03-21 20:46:23 +01:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2013-09-12 04:42:27 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2013-03-21 20:46:23 +01:00
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
|
2015-12-12 05:30:21 +01:00
|
|
|
import java.util.List;
|
2013-03-21 20:46:23 +01:00
|
|
|
|
2013-09-12 04:42:27 +02:00
|
|
|
/**
|
|
|
|
* Display the results of {@link MctopCommandAsyncTask} to the sender.
|
|
|
|
*/
|
2013-03-21 20:46:23 +01:00
|
|
|
public class MctopCommandDisplayTask extends BukkitRunnable {
|
2013-09-12 04:42:27 +02:00
|
|
|
private final List<PlayerStat> userStats;
|
|
|
|
private final CommandSender sender;
|
|
|
|
private final SkillType skill;
|
|
|
|
private final int page;
|
|
|
|
private final boolean useBoard, useChat;
|
2013-03-21 20:46:23 +01:00
|
|
|
|
2013-10-28 18:04:06 +01:00
|
|
|
MctopCommandDisplayTask(List<PlayerStat> userStats, int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
|
mcMMO - Now with 100% more scoreboards!
mcMMO now allows for the use of scoreboards to display information in
several instances. By default, all scoreboards are enabled in the config,
and will only display for 10 seconds. After 10 seconds, the scoreboard
will go away and revert to the previously displayed scoreboard, if one
exists.
A global scoreboard now exists for tracking all player stats, and will be
displayed when /mctop is used. Your name will be highlighted in gold when
looking through the scoreboard. Additionally, the scoreboard will display
players in groups of 15, rather than groups of 10 like in chat.
Unfortunately, due to the limitations of scoreboards, the player's rank
will not be displayed in front of their name.
The scoreboard area is now also used for displaying data for /mcrank,
/inspect. and /mcstats. Due to the way scoreboards are handled, the power
level is not guarenteed to show up at any given location in the
scoreboard, but is instead displayed in gold so that it can be easily
found.
Lastly, the scoreboard area is also now used for displaying current data
on skills when the relevant /<skillname> command is used. The effects and
ability stats will still be shown in chat, but the current level, xp, and
remaining xp will be shown in the scoreboard.
2013-04-14 05:16:25 +02:00
|
|
|
this.userStats = userStats;
|
2013-03-21 20:46:23 +01:00
|
|
|
this.page = page;
|
2013-06-04 18:14:43 +02:00
|
|
|
this.skill = skill;
|
2013-03-21 20:46:23 +01:00
|
|
|
this.sender = sender;
|
2013-09-12 04:42:27 +02:00
|
|
|
this.useBoard = useBoard;
|
|
|
|
this.useChat = useChat;
|
2013-03-21 20:46:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2013-09-12 04:42:27 +02:00
|
|
|
if (useBoard) {
|
|
|
|
displayBoard();
|
|
|
|
}
|
2013-10-28 18:04:06 +01:00
|
|
|
|
2013-09-12 04:42:27 +02:00
|
|
|
if (useChat) {
|
|
|
|
displayChat();
|
|
|
|
}
|
2013-10-28 18:04:06 +01:00
|
|
|
|
2014-08-24 18:21:40 +02:00
|
|
|
if (sender instanceof Player) {
|
|
|
|
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
|
|
|
}
|
2015-12-12 05:30:21 +01:00
|
|
|
if(sender instanceof Player)
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
2013-09-12 04:42:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void displayChat() {
|
2015-12-12 05:30:21 +01:00
|
|
|
|
2013-09-12 04:42:27 +02:00
|
|
|
if (skill == null) {
|
2015-12-12 05:30:21 +01:00
|
|
|
if(sender instanceof Player)
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
|
|
|
else
|
|
|
|
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")));
|
2013-03-21 20:46:23 +01:00
|
|
|
}
|
|
|
|
else {
|
2015-12-12 05:30:21 +01:00
|
|
|
if(sender instanceof Player)
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
|
|
|
|
else
|
|
|
|
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName())));
|
2013-03-21 20:46:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int place = (page * 10) - 9;
|
mcMMO - Now with 100% more scoreboards!
mcMMO now allows for the use of scoreboards to display information in
several instances. By default, all scoreboards are enabled in the config,
and will only display for 10 seconds. After 10 seconds, the scoreboard
will go away and revert to the previously displayed scoreboard, if one
exists.
A global scoreboard now exists for tracking all player stats, and will be
displayed when /mctop is used. Your name will be highlighted in gold when
looking through the scoreboard. Additionally, the scoreboard will display
players in groups of 15, rather than groups of 10 like in chat.
Unfortunately, due to the limitations of scoreboards, the player's rank
will not be displayed in front of their name.
The scoreboard area is now also used for displaying data for /mcrank,
/inspect. and /mcstats. Due to the way scoreboards are handled, the power
level is not guarenteed to show up at any given location in the
scoreboard, but is instead displayed in gold so that it can be easily
found.
Lastly, the scoreboard area is also now used for displaying current data
on skills when the relevant /<skillname> command is used. The effects and
ability stats will still be shown in chat, but the current level, xp, and
remaining xp will be shown in the scoreboard.
2013-04-14 05:16:25 +02:00
|
|
|
|
2013-06-04 18:14:43 +02:00
|
|
|
for (PlayerStat stat : userStats) {
|
2013-09-12 04:42:27 +02:00
|
|
|
// Format:
|
|
|
|
// 01. Playername - skill value
|
|
|
|
// 12. Playername - skill value
|
2015-12-12 05:30:21 +01:00
|
|
|
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, sender instanceof Player ? ChatColor.GREEN : "",
|
|
|
|
stat.name, sender instanceof Player ? ChatColor.WHITE : "", stat.statVal));
|
2013-03-21 20:46:23 +01:00
|
|
|
place++;
|
|
|
|
}
|
2013-09-12 04:42:27 +02:00
|
|
|
}
|
2013-03-21 20:46:23 +01:00
|
|
|
|
2013-09-12 04:42:27 +02:00
|
|
|
private void displayBoard() {
|
|
|
|
if (skill == null) {
|
|
|
|
ScoreboardManager.showTopPowerScoreboard((Player) sender, page, userStats);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ScoreboardManager.showTopScoreboard((Player) sender, skill, page, userStats);
|
|
|
|
}
|
2013-03-21 20:46:23 +01:00
|
|
|
}
|
|
|
|
}
|