mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Add option to use scoreboards for power level display, similar to the
Spout titles. This will NOT override any existing plugin that uses the overhead scoreboard slot.
This commit is contained in:
parent
48aafa9834
commit
aa9eb0868c
@ -26,6 +26,7 @@ Version 1.4.06-dev
|
||||
+ Added config option to multiply xp gains from mob spawner mobs
|
||||
+ Added multiplier to Archery XP based on bow force
|
||||
+ Added information about /party itemshare and /party expshare to the party help page
|
||||
+ Added option to use scoreboards for power level display instead of Spout.
|
||||
= Fixed bug where players were able to join the same party multiple times
|
||||
= Fixed displaying partial names when trying to use /ptp
|
||||
= Fixed wolves from Call of the Wild only having 8 health
|
||||
|
@ -80,6 +80,8 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
|
||||
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
|
||||
|
||||
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", true); }
|
||||
|
||||
/* Database Purging */
|
||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
|
||||
|
@ -54,6 +54,7 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
|
||||
import com.gmail.nossr50.util.Motd;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
@ -144,6 +145,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
UserManager.addUser(player).actualizeRespawnATS();
|
||||
ScoreboardManager.enablePowerLevelDisplay(player);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@ public class ScoreboardChangeTask extends BukkitRunnable {
|
||||
public void run() {
|
||||
if (player.isOnline()) {
|
||||
player.setScoreboard(oldScoreboard);
|
||||
ScoreboardManager.enablePowerLevelDisplay(player);
|
||||
}
|
||||
|
||||
ScoreboardManager.clearPendingTask(player.getName());
|
||||
|
@ -23,6 +23,7 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.runnables.scoreboards.ScoreboardChangeTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class ScoreboardManager {
|
||||
@ -32,6 +33,7 @@ public class ScoreboardManager {
|
||||
private final static String PLAYER_STATS_HEADER = "mcMMO Stats";
|
||||
private final static String PLAYER_RANK_HEADER = "mcMMO Rankings";
|
||||
private final static String PLAYER_INSPECT_HEADER = "mcMMO Stats: ";
|
||||
private final static String POWER_LEVEL_HEADER = "Power Level";
|
||||
|
||||
private final static List<String> SCOREBOARD_TASKS = new ArrayList<String>();
|
||||
|
||||
@ -43,6 +45,32 @@ public class ScoreboardManager {
|
||||
PLAYER_SCOREBOARDS.put(playerName, mcMMO.p.getServer().getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
|
||||
public static void enablePowerLevelDisplay(Player player) {
|
||||
if (!Config.getInstance().getPowerLevelsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Scoreboard scoreboard = player.getScoreboard();
|
||||
Objective objective;
|
||||
|
||||
if (scoreboard.getObjective(DisplaySlot.BELOW_NAME) == null) {
|
||||
objective = scoreboard.registerNewObjective(POWER_LEVEL_HEADER, "dummy");
|
||||
|
||||
objective.getScore(player).setScore(UserManager.getPlayer(player).getPowerLevel());
|
||||
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
}
|
||||
else {
|
||||
objective = scoreboard.getObjective(POWER_LEVEL_HEADER);
|
||||
|
||||
if (scoreboard.getObjective(POWER_LEVEL_HEADER) != null) {
|
||||
objective.getScore(player).setScore(UserManager.getPlayer(player).getPowerLevel());
|
||||
}
|
||||
else {
|
||||
mcMMO.p.debug("Another plugin is using this scoreboard slot, so power levels cannot be enabled."); //TODO: Locale
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void enablePlayerSkillScoreboard(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Scoreboard oldScoreboard = player.getScoreboard();
|
||||
@ -307,6 +335,7 @@ public class ScoreboardManager {
|
||||
String playerName = player.getName();
|
||||
|
||||
player.setScoreboard(newScoreboard);
|
||||
enablePowerLevelDisplay(player);
|
||||
|
||||
if (displayTime != -1 && !SCOREBOARD_TASKS.contains(playerName)) {
|
||||
new ScoreboardChangeTask(player, oldScoreboard).runTaskLater(mcMMO.p, displayTime * 20);
|
||||
|
@ -56,6 +56,9 @@ Scoreboards:
|
||||
Skillname:
|
||||
Use: true
|
||||
Display_Time: 10
|
||||
# Should mcMMO display power levels on scoreboards?
|
||||
Power_Level:
|
||||
Use: true
|
||||
|
||||
Mob_Healthbar:
|
||||
# Default display for mob health bars - HEARTS, BAR, or DISABLED
|
||||
|
Loading…
Reference in New Issue
Block a user