mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Use strings instead of OfflinePlayers for scoreboards.
(cherry picked from commit 89b596591ec1974e0201395dc6e76353e4709572)
This commit is contained in:
parent
9f53426511
commit
b204507a82
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -40,21 +40,21 @@ public class ScoreboardManager {
|
|||||||
|
|
||||||
static final String POWER_LEVEL = LocaleLoader.getString("Scoreboard.Misc.PowerLevel");
|
static final String POWER_LEVEL = LocaleLoader.getString("Scoreboard.Misc.PowerLevel");
|
||||||
|
|
||||||
static final OfflinePlayer LABEL_POWER_LEVEL = getOfflinePlayer(POWER_LEVEL);
|
static final String LABEL_POWER_LEVEL = POWER_LEVEL;
|
||||||
static final OfflinePlayer LABEL_LEVEL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Level"));
|
static final String LABEL_LEVEL = LocaleLoader.getString("Scoreboard.Misc.Level");
|
||||||
static final OfflinePlayer LABEL_CURRENT_XP = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.CurrentXP"));
|
static final String LABEL_CURRENT_XP = LocaleLoader.getString("Scoreboard.Misc.CurrentXP");
|
||||||
static final OfflinePlayer LABEL_REMAINING_XP = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.RemainingXP"));
|
static final String LABEL_REMAINING_XP = LocaleLoader.getString("Scoreboard.Misc.RemainingXP");
|
||||||
static final OfflinePlayer LABEL_ABILITY_COOLDOWN = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Cooldown"));
|
static final String LABEL_ABILITY_COOLDOWN = LocaleLoader.getString("Scoreboard.Misc.Cooldown");
|
||||||
static final OfflinePlayer LABEL_OVERALL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Overall"));
|
static final String LABEL_OVERALL = LocaleLoader.getString("Scoreboard.Misc.Overall");
|
||||||
|
|
||||||
static final Map<SkillType, OfflinePlayer> skillLabels;
|
static final Map<SkillType, String> skillLabels;
|
||||||
static final Map<AbilityType, OfflinePlayer> abilityLabelsColored;
|
static final Map<AbilityType, String> abilityLabelsColored;
|
||||||
static final Map<AbilityType, OfflinePlayer> abilityLabelsSkill;
|
static final Map<AbilityType, String> abilityLabelsSkill;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ImmutableMap.Builder<SkillType, OfflinePlayer> skillLabelBuilder = ImmutableMap.builder();
|
ImmutableMap.Builder<SkillType, String> skillLabelBuilder = ImmutableMap.builder();
|
||||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelBuilder = ImmutableMap.builder();
|
ImmutableMap.Builder<AbilityType, String> abilityLabelBuilder = ImmutableMap.builder();
|
||||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelSkillBuilder = ImmutableMap.builder();
|
ImmutableMap.Builder<AbilityType, String> abilityLabelSkillBuilder = ImmutableMap.builder();
|
||||||
|
|
||||||
if (Config.getInstance().getScoreboardRainbows()) {
|
if (Config.getInstance().getScoreboardRainbows()) {
|
||||||
// Everything but black, gray, gold
|
// Everything but black, gray, gold
|
||||||
@ -78,13 +78,13 @@ public class ScoreboardManager {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType type : SkillType.values()) {
|
||||||
// Include child skills
|
// Include child skills
|
||||||
skillLabelBuilder.put(type, getOfflinePlayer(colors.get(i) + type.getName()));
|
skillLabelBuilder.put(type, colors.get(i) + type.getName());
|
||||||
|
|
||||||
if (type.getAbility() != null) {
|
if (type.getAbility() != null) {
|
||||||
abilityLabelBuilder.put(type.getAbility(), getOfflinePlayer(colors.get(i) + type.getAbility().getName()));
|
abilityLabelBuilder.put(type.getAbility(),colors.get(i) + type.getAbility().getName());
|
||||||
|
|
||||||
if (type == SkillType.MINING) {
|
if (type == SkillType.MINING) {
|
||||||
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getOfflinePlayer(colors.get(i) + AbilityType.BLAST_MINING.getName()));
|
abilityLabelBuilder.put(AbilityType.BLAST_MINING, colors.get(i) + AbilityType.BLAST_MINING.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,20 +94,20 @@ public class ScoreboardManager {
|
|||||||
else {
|
else {
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType type : SkillType.values()) {
|
||||||
// Include child skills
|
// Include child skills
|
||||||
skillLabelBuilder.put(type, getOfflinePlayer(ChatColor.GREEN + type.getName()));
|
skillLabelBuilder.put(type, ChatColor.GREEN + type.getName());
|
||||||
|
|
||||||
if (type.getAbility() != null) {
|
if (type.getAbility() != null) {
|
||||||
abilityLabelBuilder.put(type.getAbility(), getOfflinePlayerDots(ChatColor.AQUA + type.getAbility().getName()));
|
abilityLabelBuilder.put(type.getAbility(), ChatColor.AQUA + type.getAbility().getName());
|
||||||
|
|
||||||
if (type == SkillType.MINING) {
|
if (type == SkillType.MINING) {
|
||||||
abilityLabelBuilder.put(AbilityType.BLAST_MINING, getOfflinePlayerDots(ChatColor.AQUA + AbilityType.BLAST_MINING.getName()));
|
abilityLabelBuilder.put(AbilityType.BLAST_MINING, ChatColor.AQUA + AbilityType.BLAST_MINING.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AbilityType type : AbilityType.values()) {
|
for (AbilityType type : AbilityType.values()) {
|
||||||
abilityLabelSkillBuilder.put(type, getOfflinePlayerDots((type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName()));
|
abilityLabelSkillBuilder.put(type, (type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
skillLabels = skillLabelBuilder.build();
|
skillLabels = skillLabelBuilder.build();
|
||||||
@ -117,22 +117,6 @@ public class ScoreboardManager {
|
|||||||
|
|
||||||
private static List<String> dirtyPowerLevels = new ArrayList<String>();
|
private static List<String> dirtyPowerLevels = new ArrayList<String>();
|
||||||
|
|
||||||
private static OfflinePlayer getOfflinePlayer(String name) {
|
|
||||||
return getOfflinePlayer(name, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static OfflinePlayer getOfflinePlayerDots(String name) {
|
|
||||||
return getOfflinePlayer(name, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static OfflinePlayer getOfflinePlayer(String name, boolean useDots) {
|
|
||||||
if (name.length() > 16) {
|
|
||||||
name = useDots ? name.substring(0, 14) + ".." : name.substring(0, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mcMMO.p.getServer().getOfflinePlayer(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum SidebarType {
|
public enum SidebarType {
|
||||||
NONE,
|
NONE,
|
||||||
SKILL_BOARD,
|
SKILL_BOARD,
|
||||||
@ -338,7 +322,7 @@ public class ScoreboardManager {
|
|||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
int power = mcMMOPlayer.getPowerLevel();
|
int power = mcMMOPlayer.getPowerLevel();
|
||||||
|
|
||||||
mainObjective.getScore(player).setScore(power);
|
mainObjective.getScore(playerName).setScore(power);
|
||||||
|
|
||||||
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
|
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
|
||||||
wrapper.updatePowerLevel(player, power);
|
wrapper.updatePowerLevel(player, power);
|
||||||
|
@ -59,7 +59,7 @@ public class ScoreboardWrapper {
|
|||||||
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||||
|
|
||||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||||
powerObjective.getScore(mcMMOPlayer.getPlayer()).setScore(mcMMOPlayer.getPowerLevel());
|
powerObjective.getScore(mcMMOPlayer.getProfile().getPlayerName()).setScore(mcMMOPlayer.getPowerLevel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,7 +274,7 @@ public class ScoreboardWrapper {
|
|||||||
targetProfile = null;
|
targetProfile = null;
|
||||||
leaderboardPage = -1;
|
leaderboardPage = -1;
|
||||||
|
|
||||||
loadObjective(ScoreboardManager.skillLabels.get(skill).getName());
|
loadObjective(ScoreboardManager.skillLabels.get(skill));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTypeSelfStats() {
|
public void setTypeSelfStats() {
|
||||||
@ -355,7 +355,7 @@ public class ScoreboardWrapper {
|
|||||||
|
|
||||||
int endPosition = page * 15;
|
int endPosition = page * 15;
|
||||||
int startPosition = endPosition - 14;
|
int startPosition = endPosition - 14;
|
||||||
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.skillLabels.get(skill).getName(), startPosition, endPosition));
|
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.skillLabels.get(skill), startPosition, endPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup for after a board type change
|
// Setup for after a board type change
|
||||||
@ -551,11 +551,11 @@ public class ScoreboardWrapper {
|
|||||||
name = ChatColor.GOLD + "--You--";
|
name = ChatColor.GOLD + "--You--";
|
||||||
}
|
}
|
||||||
|
|
||||||
sidebarObjective.getScore(mcMMO.p.getServer().getOfflinePlayer(name)).setScore(stat.statVal);
|
sidebarObjective.getScore(name).setScore(stat.statVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePowerLevel(Player player, int newPowerLevel) {
|
public void updatePowerLevel(Player player, int newPowerLevel) {
|
||||||
powerObjective.getScore(player).setScore(newPowerLevel);
|
powerObjective.getScore(player.getName()).setScore(newPowerLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user