mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Formatting cleanup from the scoreboard update. Also handle skill permissions differently.
This commit is contained in:
@ -18,7 +18,11 @@ public class McrankCommandAsyncTask extends BukkitRunnable {
|
||||
public McrankCommandAsyncTask(String playerName, CommandSender sender, boolean useBoard, boolean useChat) {
|
||||
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
|
||||
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
|
||||
if (useBoard) Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
|
||||
|
||||
if (useBoard) {
|
||||
Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
|
||||
}
|
||||
|
||||
this.playerName = playerName;
|
||||
this.sender = sender;
|
||||
this.useBoard = useBoard;
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
/**
|
||||
@ -21,7 +20,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
private final String playerName;
|
||||
private final boolean useBoard, useChat;
|
||||
|
||||
/*package-private*/ McrankCommandDisplayTask(Map<SkillType, Integer> skills, CommandSender sender, String playerName, boolean useBoard, boolean useChat) {
|
||||
McrankCommandDisplayTask(Map<SkillType, Integer> skills, CommandSender sender, String playerName, boolean useBoard, boolean useChat) {
|
||||
this.skills = skills;
|
||||
this.sender = sender;
|
||||
this.playerName = playerName;
|
||||
@ -34,6 +33,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
if (useBoard) {
|
||||
displayBoard();
|
||||
}
|
||||
|
||||
if (useChat){
|
||||
displayChat();
|
||||
}
|
||||
@ -47,12 +47,12 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
if (player != null && !Permissions.skillEnabled(player, skill)) {
|
||||
if (!skill.getPermissions(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
rank = skills.get(skill);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", skill.getSkillName(), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", skill.getName(), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
|
||||
}
|
||||
|
||||
rank = skills.get(null);
|
||||
@ -60,7 +60,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
public void displayBoard() {
|
||||
if (playerName == null || sender.getName().equalsIgnoreCase(playerName)) {
|
||||
if (sender.getName().equalsIgnoreCase(playerName)) {
|
||||
ScoreboardManager.showPlayerRankScoreboard((Player) sender, skills);
|
||||
}
|
||||
else {
|
||||
|
@ -20,7 +20,11 @@ public class MctopCommandAsyncTask extends BukkitRunnable {
|
||||
public MctopCommandAsyncTask(int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
|
||||
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
|
||||
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
|
||||
if (useBoard) Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
|
||||
|
||||
if (useBoard) {
|
||||
Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
|
||||
}
|
||||
|
||||
this.page = page;
|
||||
this.skill = skill;
|
||||
this.sender = sender;
|
||||
|
@ -22,7 +22,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
private final int page;
|
||||
private final boolean useBoard, useChat;
|
||||
|
||||
/*package-private*/ MctopCommandDisplayTask(List<PlayerStat> userStats, int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
|
||||
MctopCommandDisplayTask(List<PlayerStat> userStats, int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
|
||||
this.userStats = userStats;
|
||||
this.page = page;
|
||||
this.skill = skill;
|
||||
@ -36,9 +36,11 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
if (useBoard) {
|
||||
displayBoard();
|
||||
}
|
||||
|
||||
if (useChat) {
|
||||
displayChat();
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
|
||||
@ -47,7 +49,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getSkillName()));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
|
||||
}
|
||||
|
||||
int place = (page * 10) - 9;
|
||||
|
Reference in New Issue
Block a user