mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Reverting the scoreboard changes
Due to a naive understand of how scoreboards worked I made some incorrect assumptions and will be reverting this change
This commit is contained in:
parent
b572c0aea9
commit
bfc26dc892
@ -32,9 +32,8 @@ import com.google.common.collect.Lists;
|
|||||||
public class ScoreboardManager {
|
public class ScoreboardManager {
|
||||||
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<String, ScoreboardWrapper>();
|
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<String, ScoreboardWrapper>();
|
||||||
|
|
||||||
|
|
||||||
// do not localize; these are internal identifiers
|
// do not localize; these are internal identifiers
|
||||||
//static final String SIDEBAR_OBJECTIVE = "mcmmo_sidebar";
|
static final String SIDEBAR_OBJECTIVE = "mcmmo_sidebar";
|
||||||
static final String POWER_OBJECTIVE = "mcmmo_pwrlvl";
|
static final String POWER_OBJECTIVE = "mcmmo_pwrlvl";
|
||||||
|
|
||||||
static final String HEADER_STATS = LocaleLoader.getString("Scoreboard.Header.PlayerStats");
|
static final String HEADER_STATS = LocaleLoader.getString("Scoreboard.Header.PlayerStats");
|
||||||
@ -259,7 +258,7 @@ public class ScoreboardManager {
|
|||||||
public static void enablePlayerSkillScoreboard(Player player, PrimarySkill skill) {
|
public static void enablePlayerSkillScoreboard(Player player, PrimarySkill skill) {
|
||||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||||
|
|
||||||
//wrapper.setOldScoreboard();
|
wrapper.setOldScoreboard();
|
||||||
wrapper.setTypeSkill(skill);
|
wrapper.setTypeSkill(skill);
|
||||||
|
|
||||||
changeScoreboard(wrapper, Config.getInstance().getSkillScoreboardTime());
|
changeScoreboard(wrapper, Config.getInstance().getSkillScoreboardTime());
|
||||||
@ -273,7 +272,7 @@ public class ScoreboardManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//wrapper.setOldScoreboard();
|
wrapper.setOldScoreboard();
|
||||||
wrapper.setTypeSkill(skill);
|
wrapper.setTypeSkill(skill);
|
||||||
|
|
||||||
changeScoreboard(wrapper, Config.getInstance().getSkillLevelUpTime());
|
changeScoreboard(wrapper, Config.getInstance().getSkillLevelUpTime());
|
||||||
@ -282,7 +281,7 @@ public class ScoreboardManager {
|
|||||||
public static void enablePlayerStatsScoreboard(Player player) {
|
public static void enablePlayerStatsScoreboard(Player player) {
|
||||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||||
|
|
||||||
//wrapper.setOldScoreboard();
|
wrapper.setOldScoreboard();
|
||||||
wrapper.setTypeSelfStats();
|
wrapper.setTypeSelfStats();
|
||||||
|
|
||||||
changeScoreboard(wrapper, Config.getInstance().getStatsScoreboardTime());
|
changeScoreboard(wrapper, Config.getInstance().getStatsScoreboardTime());
|
||||||
@ -291,7 +290,7 @@ public class ScoreboardManager {
|
|||||||
public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) {
|
public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) {
|
||||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||||
|
|
||||||
//wrapper.setOldScoreboard();
|
wrapper.setOldScoreboard();
|
||||||
wrapper.setTypeInspectStats(targetProfile);
|
wrapper.setTypeInspectStats(targetProfile);
|
||||||
|
|
||||||
changeScoreboard(wrapper, Config.getInstance().getInspectScoreboardTime());
|
changeScoreboard(wrapper, Config.getInstance().getInspectScoreboardTime());
|
||||||
@ -300,7 +299,7 @@ public class ScoreboardManager {
|
|||||||
public static void enablePlayerCooldownScoreboard(Player player) {
|
public static void enablePlayerCooldownScoreboard(Player player) {
|
||||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||||
|
|
||||||
//wrapper.setOldScoreboard();
|
wrapper.setOldScoreboard();
|
||||||
wrapper.setTypeCooldowns();
|
wrapper.setTypeCooldowns();
|
||||||
|
|
||||||
changeScoreboard(wrapper, Config.getInstance().getCooldownScoreboardTime());
|
changeScoreboard(wrapper, Config.getInstance().getCooldownScoreboardTime());
|
||||||
@ -309,7 +308,7 @@ public class ScoreboardManager {
|
|||||||
public static void showPlayerRankScoreboard(Player player, Map<PrimarySkill, Integer> rank) {
|
public static void showPlayerRankScoreboard(Player player, Map<PrimarySkill, Integer> rank) {
|
||||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||||
|
|
||||||
//wrapper.setOldScoreboard();
|
wrapper.setOldScoreboard();
|
||||||
wrapper.setTypeSelfRank();
|
wrapper.setTypeSelfRank();
|
||||||
wrapper.acceptRankData(rank);
|
wrapper.acceptRankData(rank);
|
||||||
|
|
||||||
@ -319,7 +318,7 @@ public class ScoreboardManager {
|
|||||||
public static void showPlayerRankScoreboardOthers(Player player, String targetName, Map<PrimarySkill, Integer> rank) {
|
public static void showPlayerRankScoreboardOthers(Player player, String targetName, Map<PrimarySkill, Integer> rank) {
|
||||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||||
|
|
||||||
//wrapper.setOldScoreboard();
|
wrapper.setOldScoreboard();
|
||||||
wrapper.setTypeInspectRank(targetName);
|
wrapper.setTypeInspectRank(targetName);
|
||||||
wrapper.acceptRankData(rank);
|
wrapper.acceptRankData(rank);
|
||||||
|
|
||||||
@ -329,7 +328,7 @@ public class ScoreboardManager {
|
|||||||
public static void showTopScoreboard(Player player, PrimarySkill skill, int pageNumber, List<PlayerStat> stats) {
|
public static void showTopScoreboard(Player player, PrimarySkill skill, int pageNumber, List<PlayerStat> stats) {
|
||||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||||
|
|
||||||
//wrapper.setOldScoreboard();
|
wrapper.setOldScoreboard();
|
||||||
wrapper.setTypeTop(skill, pageNumber);
|
wrapper.setTypeTop(skill, pageNumber);
|
||||||
wrapper.acceptLeaderboardData(stats);
|
wrapper.acceptLeaderboardData(stats);
|
||||||
|
|
||||||
@ -339,7 +338,7 @@ public class ScoreboardManager {
|
|||||||
public static void showTopPowerScoreboard(Player player, int pageNumber, List<PlayerStat> stats) {
|
public static void showTopPowerScoreboard(Player player, int pageNumber, List<PlayerStat> stats) {
|
||||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||||
|
|
||||||
//wrapper.setOldScoreboard();
|
wrapper.setOldScoreboard();
|
||||||
wrapper.setTypeTopPower(pageNumber);
|
wrapper.setTypeTopPower(pageNumber);
|
||||||
wrapper.acceptLeaderboardData(stats);
|
wrapper.acceptLeaderboardData(stats);
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.util.scoreboards;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -31,9 +30,7 @@ import org.apache.commons.lang.Validate;
|
|||||||
public class ScoreboardWrapper {
|
public class ScoreboardWrapper {
|
||||||
// Initialization variables
|
// Initialization variables
|
||||||
public final String playerName;
|
public final String playerName;
|
||||||
public final UUID playerUUID;
|
|
||||||
private final Scoreboard scoreboard;
|
private final Scoreboard scoreboard;
|
||||||
private final Player player;
|
|
||||||
private boolean tippedKeep = false;
|
private boolean tippedKeep = false;
|
||||||
private boolean tippedClear = false;
|
private boolean tippedClear = false;
|
||||||
|
|
||||||
@ -49,25 +46,12 @@ public class ScoreboardWrapper {
|
|||||||
private PlayerProfile targetProfile = null;
|
private PlayerProfile targetProfile = null;
|
||||||
public int leaderboardPage = -1;
|
public int leaderboardPage = -1;
|
||||||
|
|
||||||
private ScoreboardWrapper(Player player, Scoreboard scoreboard) {
|
private ScoreboardWrapper(String playerName, Scoreboard scoreboard) {
|
||||||
this.player = player;
|
this.playerName = playerName;
|
||||||
this.playerName = player.getName();
|
|
||||||
this.scoreboard = scoreboard;
|
this.scoreboard = scoreboard;
|
||||||
this.playerUUID = player.getUniqueId();
|
|
||||||
sidebarType = SidebarType.NONE;
|
sidebarType = SidebarType.NONE;
|
||||||
|
sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||||
if(this.scoreboard.getObjective(getObjectiveIdentifier(ObjectiveType.SIDEBAR)) == null)
|
powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy");
|
||||||
sidebarObjective = this.scoreboard.registerNewObjective(getObjectiveIdentifier(ObjectiveType.SIDEBAR), "dummy");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.scoreboard.getObjective(getObjectiveIdentifier(ObjectiveType.SIDEBAR)).unregister();
|
|
||||||
sidebarObjective = this.scoreboard.registerNewObjective(getObjectiveIdentifier(ObjectiveType.SIDEBAR), "dummy");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.scoreboard.getObjective(getObjectiveIdentifier(ObjectiveType.POWER)) == null)
|
|
||||||
powerObjective = this.scoreboard.registerNewObjective(getObjectiveIdentifier(ObjectiveType.POWER), "dummy");
|
|
||||||
else
|
|
||||||
powerObjective = this.scoreboard.getObjective(getObjectiveIdentifier(ObjectiveType.POWER));
|
|
||||||
|
|
||||||
if (Config.getInstance().getPowerLevelTagsEnabled()) {
|
if (Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||||
powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
||||||
@ -79,22 +63,8 @@ public class ScoreboardWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getObjectiveIdentifier(ObjectiveType objectiveType)
|
|
||||||
{
|
|
||||||
switch(objectiveType)
|
|
||||||
{
|
|
||||||
case POWER:
|
|
||||||
return ScoreboardManager.POWER_OBJECTIVE;
|
|
||||||
case SIDEBAR:
|
|
||||||
return playerName;
|
|
||||||
default:
|
|
||||||
return playerName;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ScoreboardWrapper create(Player player) {
|
public static ScoreboardWrapper create(Player player) {
|
||||||
return new ScoreboardWrapper(player, getMainScoreboard());
|
return new ScoreboardWrapper(player.getName(), mcMMO.p.getServer().getScoreboardManager().getNewScoreboard());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitTask updateTask = null;
|
public BukkitTask updateTask = null;
|
||||||
@ -175,7 +145,7 @@ public class ScoreboardWrapper {
|
|||||||
/**
|
/**
|
||||||
* Set the old scoreboard, for use in reverting.
|
* Set the old scoreboard, for use in reverting.
|
||||||
*/
|
*/
|
||||||
/*public void setOldScoreboard() {
|
public void setOldScoreboard() {
|
||||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
@ -194,7 +164,7 @@ public class ScoreboardWrapper {
|
|||||||
else {
|
else {
|
||||||
this.oldBoard = oldBoard;
|
this.oldBoard = oldBoard;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
public void showBoardWithNoRevert() {
|
public void showBoardWithNoRevert() {
|
||||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||||
@ -255,7 +225,7 @@ public class ScoreboardWrapper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldBoard != null && oldBoard != player.getScoreboard()) {
|
if (oldBoard != null) {
|
||||||
if (player.getScoreboard() == scoreboard) {
|
if (player.getScoreboard() == scoreboard) {
|
||||||
player.setScoreboard(oldBoard);
|
player.setScoreboard(oldBoard);
|
||||||
oldBoard = null;
|
oldBoard = null;
|
||||||
@ -267,13 +237,6 @@ public class ScoreboardWrapper {
|
|||||||
|
|
||||||
cancelRevert();
|
cancelRevert();
|
||||||
|
|
||||||
//Unregister the boards
|
|
||||||
if (getMainScoreboard().getObjective(getObjectiveIdentifier(ObjectiveType.SIDEBAR)) != null)
|
|
||||||
{
|
|
||||||
getMainScoreboard().getObjective(getObjectiveIdentifier(ObjectiveType.SIDEBAR)).unregister();
|
|
||||||
} else
|
|
||||||
unregisterPlayerSideboard(getObjectiveIdentifier(ObjectiveType.POWER));
|
|
||||||
|
|
||||||
sidebarType = SidebarType.NONE;
|
sidebarType = SidebarType.NONE;
|
||||||
targetPlayer = null;
|
targetPlayer = null;
|
||||||
targetSkill = null;
|
targetSkill = null;
|
||||||
@ -408,18 +371,8 @@ public class ScoreboardWrapper {
|
|||||||
|
|
||||||
// Setup for after a board type change
|
// Setup for after a board type change
|
||||||
protected void loadObjective(String displayName) {
|
protected void loadObjective(String displayName) {
|
||||||
//Unregister the old sidebarobjective if it exists
|
sidebarObjective.unregister();
|
||||||
try {
|
sidebarObjective = scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||||
if (getMainScoreboard().getObjective(getObjectiveIdentifier(ObjectiveType.SIDEBAR)) != null)
|
|
||||||
getMainScoreboard().getObjective(getObjectiveIdentifier(ObjectiveType.SIDEBAR)).unregister();
|
|
||||||
} catch (IllegalStateException exception)
|
|
||||||
{
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
//Unregister our player-named sideboard if it exists
|
|
||||||
unregisterPlayerSideboard(player.getName());
|
|
||||||
|
|
||||||
sidebarObjective = scoreboard.registerNewObjective(getObjectiveIdentifier(ObjectiveType.SIDEBAR), "dummy");
|
|
||||||
|
|
||||||
if (displayName.length() > 32) {
|
if (displayName.length() > 32) {
|
||||||
displayName = displayName.substring(0, 32);
|
displayName = displayName.substring(0, 32);
|
||||||
@ -432,15 +385,6 @@ public class ScoreboardWrapper {
|
|||||||
sidebarObjective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
sidebarObjective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unregisterPlayerSideboard(String s) {
|
|
||||||
if (getMainScoreboard().getObjective(s) != null)
|
|
||||||
getMainScoreboard().getObjective(s).unregister();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Scoreboard getMainScoreboard() {
|
|
||||||
return mcMMO.p.getServer().getScoreboardManager().getMainScoreboard();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load new values into the sidebar.
|
* Load new values into the sidebar.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user