mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Players need to have unique objectives
This commit is contained in:
@ -5,6 +5,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.json.McMMOUrl;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkill;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
@ -26,12 +27,68 @@ public class TextComponentFactory {
|
||||
|
||||
public static BaseComponent[] webComponents;
|
||||
|
||||
public static TextComponent getNotificationTextComponent(String localeKey, NotificationType notificationType)
|
||||
/**
|
||||
* This one is a bit simple
|
||||
* @param localeKey
|
||||
* @param notificationType
|
||||
* @param values
|
||||
* @return
|
||||
*/
|
||||
public static TextComponent getNotificationTextComponentFromLocale(String localeKey, NotificationType notificationType, String... values)
|
||||
{
|
||||
TextComponent textComponent = new TextComponent(LocaleLoader.getString(localeKey));
|
||||
//TODO: Make this colored
|
||||
return new TextComponent(LocaleLoader.getString(localeKey, values));
|
||||
}
|
||||
|
||||
public static TextComponent getNotificationTextComponentFromLocale(String localeKey, NotificationType notificationType)
|
||||
{
|
||||
return getNotificationTextComponent(LocaleLoader.getString(localeKey), notificationType);
|
||||
}
|
||||
|
||||
public static TextComponent getNotificationLevelUpTextComponent(McMMOPlayer player, PrimarySkill skill, int currentLevel)
|
||||
{
|
||||
//player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(primarySkill.toString()) + ".Skillup", levelsGained, getSkillLevel(primarySkill)));
|
||||
TextComponent textComponent = new TextComponent(LocaleLoader.getString("JSON."+StringUtils.getCapitalized(skill.toString()))
|
||||
+" "+LocaleLoader.getString("JSON.LevelUp"));
|
||||
textComponent.setColor(AdvancedConfig.getInstance().getJSONActionBarColor(NotificationType.LEVEL_UP_MESSAGE));
|
||||
TextComponent childComponent = new TextComponent(" "+currentLevel);
|
||||
//TODO: Config
|
||||
childComponent.setColor(ChatColor.GREEN);
|
||||
childComponent.setBold(true);
|
||||
textComponent.addExtra(childComponent);
|
||||
return textComponent;
|
||||
}
|
||||
|
||||
public static TextComponent getNotificationTextComponent(String text, NotificationType notificationType)
|
||||
{
|
||||
System.out.println("Test");
|
||||
TextComponent textComponent = new TextComponent(text);
|
||||
textComponent.setColor(getNotificationColor(notificationType));
|
||||
return textComponent;
|
||||
}
|
||||
|
||||
public static ChatColor getNotificationColor(NotificationType notificationType)
|
||||
{
|
||||
ChatColor color = ChatColor.WHITE;
|
||||
switch(notificationType)
|
||||
{
|
||||
case SUPER_ABILITY:
|
||||
break;
|
||||
case TOOL:
|
||||
break;
|
||||
case SUBSKILL_UNLOCKED:
|
||||
break;
|
||||
case SUBSKILL_MESSAGE:
|
||||
break;
|
||||
case LEVEL_UP_MESSAGE:
|
||||
break;
|
||||
case XP_GAIN:
|
||||
break;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
public static void sendPlayerUrlHeader(Player player) {
|
||||
if(!Config.getInstance().getUrlLinksEnabled())
|
||||
return;
|
||||
|
@ -0,0 +1,6 @@
|
||||
package com.gmail.nossr50.util.scoreboards;
|
||||
|
||||
public enum ObjectiveType {
|
||||
SIDEBAR,
|
||||
POWER
|
||||
}
|
@ -32,8 +32,9 @@ import com.google.common.collect.Lists;
|
||||
public class ScoreboardManager {
|
||||
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<String, ScoreboardWrapper>();
|
||||
|
||||
|
||||
// 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 HEADER_STATS = LocaleLoader.getString("Scoreboard.Header.PlayerStats");
|
||||
@ -401,7 +402,7 @@ public class ScoreboardManager {
|
||||
Objective powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
|
||||
|
||||
if (powerObjective == null) {
|
||||
powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy");
|
||||
powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy");
|
||||
powerObjective.setDisplayName(TAG_POWER_LEVEL);
|
||||
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.util.scoreboards;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -30,6 +31,7 @@ import org.apache.commons.lang.Validate;
|
||||
public class ScoreboardWrapper {
|
||||
// Initialization variables
|
||||
public final String playerName;
|
||||
public final UUID playerUUID;
|
||||
private final Scoreboard scoreboard;
|
||||
private boolean tippedKeep = false;
|
||||
private boolean tippedClear = false;
|
||||
@ -46,12 +48,24 @@ public class ScoreboardWrapper {
|
||||
private PlayerProfile targetProfile = null;
|
||||
public int leaderboardPage = -1;
|
||||
|
||||
private ScoreboardWrapper(String playerName, Scoreboard scoreboard) {
|
||||
this.playerName = playerName;
|
||||
private ScoreboardWrapper(Player player, Scoreboard scoreboard) {
|
||||
this.playerName = player.getName();
|
||||
this.scoreboard = scoreboard;
|
||||
this.playerUUID = player.getUniqueId();
|
||||
sidebarType = SidebarType.NONE;
|
||||
sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||
powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy");
|
||||
|
||||
if(this.scoreboard.getObjective(getObjective(ObjectiveType.SIDEBAR)) == null)
|
||||
sidebarObjective = this.scoreboard.registerNewObjective(getObjective(ObjectiveType.SIDEBAR), "dummy");
|
||||
else
|
||||
{
|
||||
this.scoreboard.getObjective(getObjective(ObjectiveType.SIDEBAR)).unregister();
|
||||
sidebarObjective = this.scoreboard.registerNewObjective(getObjective(ObjectiveType.SIDEBAR), "dummy");
|
||||
}
|
||||
|
||||
if(this.scoreboard.getObjective(getObjective(ObjectiveType.POWER)) == null)
|
||||
powerObjective = this.scoreboard.registerNewObjective(getObjective(ObjectiveType.POWER), "dummy");
|
||||
else
|
||||
powerObjective = this.scoreboard.getObjective(getObjective(ObjectiveType.POWER));
|
||||
|
||||
if (Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||
powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
||||
@ -63,8 +77,22 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public String getObjective(ObjectiveType objectiveType)
|
||||
{
|
||||
switch(objectiveType)
|
||||
{
|
||||
case POWER:
|
||||
return ScoreboardManager.POWER_OBJECTIVE;
|
||||
case SIDEBAR:
|
||||
return playerName;
|
||||
default:
|
||||
return playerName;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static ScoreboardWrapper create(Player player) {
|
||||
return new ScoreboardWrapper(player.getName(), mcMMO.p.getServer().getScoreboardManager().getMainScoreboard());
|
||||
return new ScoreboardWrapper(player, mcMMO.p.getServer().getScoreboardManager().getMainScoreboard());
|
||||
}
|
||||
|
||||
public BukkitTask updateTask = null;
|
||||
@ -372,7 +400,7 @@ public class ScoreboardWrapper {
|
||||
// Setup for after a board type change
|
||||
protected void loadObjective(String displayName) {
|
||||
sidebarObjective.unregister();
|
||||
sidebarObjective = scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||
sidebarObjective = scoreboard.registerNewObjective(getObjective(ObjectiveType.SIDEBAR), "dummy");
|
||||
|
||||
if (displayName.length() > 32) {
|
||||
displayName = displayName.substring(0, 32);
|
||||
|
Reference in New Issue
Block a user