if (player == null) {
ScoreboardManager.cleanup(this);
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
switch (sidebarType) {
case NONE:
break;
case SKILL_BOARD:
Validate.notNull(targetSkill);
if (!targetSkill.isChildSkill()) {
int currentXP = mcMMOPlayer.getSkillXpLevel(targetSkill);
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
}
else {
for (SkillType parentSkill : FamilyTree.getParents(targetSkill)) {
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(mcMMOPlayer.getSkillLevel(parentSkill));
}
}
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(mcMMOPlayer.getSkillLevel(targetSkill));
if (targetSkill.getAbility() != null) {
boolean stopUpdating;
if (targetSkill == SkillType.MINING) {
// Special-Case: Mining has two abilities, both with cooldowns
Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.SUPER_BREAKER));
Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.BLAST_MINING));
int secondsSB = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.SUPER_BREAKER), 0);
int secondsBM = Math.max(mcMMOPlayer.calculateTimeRemaining(AbilityType.BLAST_MINING), 0);
cooldownSB.setScore(secondsSB);
cooldownBM.setScore(secondsBM);
stopUpdating = (secondsSB == 0 && secondsBM == 0);
}
else {
AbilityType ability = targetSkill.getAbility();
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
cooldown.setScore(seconds);
stopUpdating = seconds == 0;
}
if (stopUpdating) {
stopCooldownUpdating();
}
else {
startCooldownUpdating();
}
}
break;
case COOLDOWNS_BOARD:
boolean anyCooldownsActive = false;
for (AbilityType ability : AbilityType.values()) {
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
if (seconds != 0) {
anyCooldownsActive = true;
}
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
}
if (anyCooldownsActive) {
startCooldownUpdating();
}
else {
stopCooldownUpdating();
}
break;
case STATS_BOARD:
// Select the profile to read from
PlayerProfile newProfile;
if (targetProfile != null) {
newProfile = targetProfile; // offline
}
else if (targetPlayer == null) {
newProfile = mcMMOPlayer.getProfile(); // self
}
else {
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
}