mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Fix formatting
(cherry picked from commit 4e36073e6e2dc3aeba087d605cef79fc4a8a9779)
This commit is contained in:
parent
b204507a82
commit
bfebbd0095
@ -7,7 +7,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
@ -81,14 +80,16 @@ public class ScoreboardManager {
|
||||
skillLabelBuilder.put(type, colors.get(i) + type.getName());
|
||||
|
||||
if (type.getAbility() != null) {
|
||||
abilityLabelBuilder.put(type.getAbility(),colors.get(i) + type.getAbility().getName());
|
||||
abilityLabelBuilder.put(type.getAbility(), colors.get(i) + type.getAbility().getName());
|
||||
|
||||
if (type == SkillType.MINING) {
|
||||
abilityLabelBuilder.put(AbilityType.BLAST_MINING, colors.get(i) + AbilityType.BLAST_MINING.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (++i == colors.size()) i = 0;
|
||||
if (++i == colors.size()) {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -335,7 +336,7 @@ public class ScoreboardManager {
|
||||
|
||||
/**
|
||||
* Gets or creates the power level objective on the main scoreboard.
|
||||
* <p>
|
||||
* <p/>
|
||||
* If power levels are disabled, the objective is deleted and null is
|
||||
* returned.
|
||||
*
|
||||
|
@ -28,7 +28,6 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
public class ScoreboardWrapper {
|
||||
|
||||
// Initialization variables
|
||||
public final String playerName;
|
||||
private final Scoreboard scoreboard;
|
||||
@ -69,6 +68,7 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
|
||||
public BukkitTask updateTask = null;
|
||||
|
||||
private class ScoreboardQuickUpdate extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -78,6 +78,7 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
|
||||
public BukkitTask revertTask = null;
|
||||
|
||||
private class ScoreboardChangeTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -87,6 +88,7 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
|
||||
public BukkitTask cooldownTask = null;
|
||||
|
||||
private class ScoreboardCooldownTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -121,7 +123,8 @@ public class ScoreboardWrapper {
|
||||
try {
|
||||
cooldownTask.cancel();
|
||||
}
|
||||
catch (Throwable ignored) {}
|
||||
catch (Throwable ignored) {
|
||||
}
|
||||
|
||||
cooldownTask = null;
|
||||
}
|
||||
@ -381,7 +384,8 @@ public class ScoreboardWrapper {
|
||||
try {
|
||||
updateTask.cancel();
|
||||
}
|
||||
catch (Throwable ignored) {} // catch NullPointerException and IllegalStateException and any Error; don't care
|
||||
catch (Throwable ignored) {
|
||||
} // catch NullPointerException and IllegalStateException and any Error; don't care
|
||||
|
||||
updateTask = null;
|
||||
|
||||
@ -399,124 +403,125 @@ public class ScoreboardWrapper {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
switch (sidebarType) {
|
||||
case NONE:
|
||||
break;
|
||||
case NONE:
|
||||
break;
|
||||
|
||||
case SKILL_BOARD:
|
||||
Validate.notNull(targetSkill);
|
||||
case SKILL_BOARD:
|
||||
Validate.notNull(targetSkill);
|
||||
|
||||
if (!targetSkill.isChildSkill()) {
|
||||
int currentXP = mcMMOPlayer.getSkillXpLevel(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);
|
||||
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
|
||||
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
|
||||
}
|
||||
else {
|
||||
AbilityType ability = targetSkill.getAbility();
|
||||
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
|
||||
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);
|
||||
|
||||
cooldown.setScore(seconds);
|
||||
if (seconds != 0) {
|
||||
anyCooldownsActive = true;
|
||||
}
|
||||
|
||||
stopUpdating = seconds == 0;
|
||||
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
|
||||
}
|
||||
|
||||
if (stopUpdating) {
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
else {
|
||||
if (anyCooldownsActive) {
|
||||
startCooldownUpdating();
|
||||
}
|
||||
}
|
||||
break;
|
||||
else {
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
break;
|
||||
|
||||
case COOLDOWNS_BOARD:
|
||||
boolean anyCooldownsActive = false;
|
||||
case STATS_BOARD:
|
||||
// Select the profile to read from
|
||||
PlayerProfile newProfile;
|
||||
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
|
||||
|
||||
if (seconds != 0) {
|
||||
anyCooldownsActive = true;
|
||||
if (targetProfile != null) {
|
||||
newProfile = targetProfile; // offline
|
||||
}
|
||||
else if (targetPlayer == null) {
|
||||
newProfile = mcMMOPlayer.getProfile(); // self
|
||||
}
|
||||
else {
|
||||
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
|
||||
}
|
||||
|
||||
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
|
||||
}
|
||||
// Calculate power level here
|
||||
int powerLevel = 0;
|
||||
for (SkillType skill : SkillType.values()) { // Include child skills, but not in power level
|
||||
int level = newProfile.getSkillLevel(skill);
|
||||
|
||||
if (anyCooldownsActive) {
|
||||
startCooldownUpdating();
|
||||
}
|
||||
else {
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
break;
|
||||
if (!skill.isChildSkill()) {
|
||||
powerLevel += level;
|
||||
}
|
||||
|
||||
case STATS_BOARD:
|
||||
// Select the profile to read from
|
||||
PlayerProfile newProfile;
|
||||
// TODO: Verify that this is what we want - calculated in power level but not displayed
|
||||
if (!skill.getPermissions(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (targetProfile != null) {
|
||||
newProfile = targetProfile; // offline
|
||||
}
|
||||
else if (targetPlayer == null) {
|
||||
newProfile = mcMMOPlayer.getProfile(); // self
|
||||
}
|
||||
else {
|
||||
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
|
||||
}
|
||||
|
||||
// Calculate power level here
|
||||
int powerLevel = 0;
|
||||
for (SkillType skill : SkillType.values()) { // Include child skills, but not in power level
|
||||
int level = newProfile.getSkillLevel(skill);
|
||||
|
||||
if (!skill.isChildSkill())
|
||||
powerLevel += level;
|
||||
|
||||
// TODO: Verify that this is what we want - calculated in power level but not displayed
|
||||
if (!skill.getPermissions(player)) {
|
||||
continue;
|
||||
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
|
||||
}
|
||||
|
||||
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
|
||||
}
|
||||
sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
|
||||
break;
|
||||
|
||||
sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
|
||||
break;
|
||||
|
||||
case RANK_BOARD:
|
||||
case TOP_BOARD:
|
||||
case RANK_BOARD:
|
||||
case TOP_BOARD:
|
||||
/*
|
||||
* @see #acceptRankData(Map<SkillType, Integer> rank)
|
||||
* @see #acceptLeaderboardData(List<PlayerStat> stats)
|
||||
*/
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user