mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
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.
This commit is contained in:
@ -32,7 +32,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
|
||||
if (skill.isChildSkill() || (player != null && !Permissions.skillEnabled(player, skill))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -11,7 +11,6 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.SQLDatabaseManager;
|
||||
|
||||
public class MctopCommandAsyncTask extends BukkitRunnable {
|
||||
|
||||
private CommandSender sender;
|
||||
private String query;
|
||||
private int page;
|
||||
@ -25,8 +24,8 @@ public class MctopCommandAsyncTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
final HashMap<Integer, ArrayList<String>> userslist = SQLDatabaseManager.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT " + ((page * 10) - 10) + ",10");
|
||||
final Collection<ArrayList<String>> userStats = SQLDatabaseManager.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT " + ((page * 10) - 10) + ",10").values();
|
||||
|
||||
new MctopCommandDisplayTask(userslist, page, tablePrefix, sender).runTaskLater(mcMMO.p, 1);
|
||||
new MctopCommandDisplayTask(userStats, page, tablePrefix, sender).runTaskLater(mcMMO.p, 1);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.runnables.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -11,13 +11,13 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
private HashMap<Integer, ArrayList<String>> userslist;
|
||||
private Collection<ArrayList<String>> userStats;
|
||||
private CommandSender sender;
|
||||
private String query;
|
||||
private int page;
|
||||
|
||||
public MctopCommandDisplayTask(HashMap<Integer, ArrayList<String>> userslist, int page, String query, CommandSender sender) {
|
||||
this.userslist = userslist;
|
||||
public MctopCommandDisplayTask(Collection<ArrayList<String>> userStats, int page, String query, CommandSender sender) {
|
||||
this.userStats = userStats;
|
||||
this.page = page;
|
||||
this.query = query;
|
||||
this.sender = sender;
|
||||
@ -33,13 +33,12 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
int place = (page * 10) - 9;
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
if (userslist.get(i) == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (ArrayList<String> stat : userStats) {
|
||||
String digit = (place < 10) ? "0" : "" + String.valueOf(place);
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(place + ". " + ChatColor.GREEN + userslist.get(i).get(1) + " - " + ChatColor.WHITE + userslist.get(i).get(0));
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + stat.get(1) + " - " + ChatColor.WHITE + stat.get(0));
|
||||
place++;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.gmail.nossr50.runnables.scoreboards;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
public class ScoreboardChangeTask extends BukkitRunnable {
|
||||
private Player player;
|
||||
private Scoreboard oldScoreboard;
|
||||
|
||||
public ScoreboardChangeTask(Player player, Scoreboard oldScoreboard) {
|
||||
this.player = player;
|
||||
this.oldScoreboard = oldScoreboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.setScoreboard(oldScoreboard);
|
||||
ScoreboardManager.clearPendingTask(player.getName());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user