From f11b98c29d171ab0a06f1aa5d68cd9dc701afa20 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 11 Jan 2019 05:26:05 -0800 Subject: [PATCH] Players need to have unique objectives --- Changelog.txt | 3 + .../gmail/nossr50/config/AdvancedConfig.java | 15 ++++- .../interactions/NotificationType.java | 27 ++++++-- .../nossr50/datatypes/player/McMMOPlayer.java | 15 +++-- .../nossr50/datatypes/skills/ToolType.java | 12 ++-- .../skills/McMMOPlayerNotificationEvent.java | 43 ++++++------ .../nossr50/listeners/InteractionManager.java | 66 +++++++++++++++---- .../runnables/skills/ToolLowerTask.java | 4 +- .../nossr50/util/TextComponentFactory.java | 61 ++++++++++++++++- .../util/scoreboards/ObjectiveType.java | 6 ++ .../util/scoreboards/ScoreboardManager.java | 5 +- .../util/scoreboards/ScoreboardWrapper.java | 40 +++++++++-- src/main/resources/advanced.yml | 40 +++++------ .../resources/locale/locale_en_US.properties | 15 +++++ 14 files changed, 262 insertions(+), 90 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/util/scoreboards/ObjectiveType.java diff --git a/Changelog.txt b/Changelog.txt index c515b8871..c5ce72c6b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -15,6 +15,9 @@ Version 2.1.0 + Added links to mcMMO related websites to various commands + Certain elements of mcMMO's UI have been restyled + Added the tagline "Overhaul Era" to various locations until 3.0.0 comes out + + (Skills) Tool alerts now are sent to the Action Bar + + (Skills) Super Ability activation alerts are now sent to the Action Bar + + (Skills) Certain Skill messages are now sent to the Action Bar + (Config) Added option to disable the new URL links to config.yml + (Config) New config file added coreskills.yml + (Config) Added rank settings for the new Woodcutting skill diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 0784add85..53e80f0c3 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -711,7 +711,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { case SUBSKILL_UNLOCKED: key = "SubSkillUnlocked"; break; - case TOOL_READY: + case TOOL: key = "ToolReady"; break; case SUPER_ABILITY: @@ -781,16 +781,25 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { return config.getBoolean("Style.JSON.Hover.Details.Description.Underlined"); } + public ChatColor getJSONActionBarColor(NotificationType notificationType) + { + return getChatColor(LocaleLoader.getString("Style.JSON.Notification."+notificationType.toString()+".Color")); + } + private ChatColor getChatColorFromKey(String keyLocation) { String colorName = LocaleLoader.getString(keyLocation); + return getChatColor(colorName); + } + + private ChatColor getChatColor(String configColor) { for (ChatColor chatColor : ChatColor.values()) { - if (colorName.equalsIgnoreCase(chatColor.toString())) + if (configColor.equalsIgnoreCase(chatColor.getName())) return chatColor; } //Invalid Color - System.out.println("[mcMMO] " + colorName + " is an invalid color value for key " + keyLocation); + System.out.println("[mcMMO] " + configColor + " is an invalid color value"); return ChatColor.WHITE; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java b/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java index 5fee085f4..6a28bf662 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java @@ -4,10 +4,23 @@ package com.gmail.nossr50.datatypes.interactions; * This class helps define the types of information interactions we will have with players */ public enum NotificationType { - XP_GAIN, - SUBSKILL_UNLOCKED, - LEVEL_UP_MESSAGE, - SUBSKILL_MESSAGE, - TOOL_READY, - SUPER_ABILITY -} + XP_GAIN("ExperienceGain"), + SUBSKILL_UNLOCKED("SubSkillUnlocked"), + LEVEL_UP_MESSAGE("LevelUps"), + SUBSKILL_MESSAGE("SubSkillInteraction"), + TOOL("ToolReady"), + UNSKILLED("LevelRequirementNotMet"), + ABILITY_COOLDOWN("AbilityCoolDown"), + SUPER_ABILITY("SuperAbilityInteraction"); + + final String niceName; + + NotificationType(String niceName) + { + this.niceName = niceName; + } + + @Override + public String toString() { + return niceName; + }} diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 1bd7485be..0ec12e413 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.chat.ChatMode; +import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.mods.CustomTool; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; @@ -11,6 +12,7 @@ import com.gmail.nossr50.datatypes.skills.SuperAbility; import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.skills.XPGainReason; +import com.gmail.nossr50.listeners.InteractionManager; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.party.PartyManager; @@ -38,7 +40,6 @@ import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.skills.ParticleEffectUtils; @@ -514,7 +515,8 @@ public class McMMOPlayer { player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH); } - player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(primarySkill.toString()) + ".Skillup", levelsGained, getSkillLevel(primarySkill))); + InteractionManager.sendPlayerLevelUpNotification(UserManager.getPlayer(player), primarySkill, profile.getSkillLevel(primarySkill)); + //player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(primarySkill.toString()) + ".Skillup", levelsGained, getSkillLevel(primarySkill))); } /* @@ -729,8 +731,6 @@ public class McMMOPlayer { ToolType tool = skill.getTool(); SuperAbility ability = skill.getAbility(); - setToolPreparationMode(tool, false); - if (getAbilityMode(ability)) { return; } @@ -785,6 +785,7 @@ public class McMMOPlayer { SkillUtils.handleAbilitySpeedIncrease(player); } + setToolPreparationMode(tool, false); new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR); } @@ -811,6 +812,7 @@ public class McMMOPlayer { SuperAbility ability = skill.getAbility(); ToolType tool = skill.getTool(); + setToolPreparationMode(tool, true); /* * Woodcutting & Axes need to be treated differently. @@ -821,16 +823,15 @@ public class McMMOPlayer { int timeRemaining = calculateTimeRemaining(ability); if (!getAbilityMode(ability) && timeRemaining > 0) { - player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining)); + InteractionManager.sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); return; } } if (Config.getInstance().getAbilityMessagesEnabled()) { - player.sendMessage(tool.getRaiseTool()); + InteractionManager.sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool()); } - setToolPreparationMode(tool, true); new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java index 666acae32..5bf6474ee 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java @@ -7,12 +7,12 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.ItemUtils; public enum ToolType { - AXE(LocaleLoader.getString("Axes.Ability.Lower"), LocaleLoader.getString("Axes.Ability.Ready")), - FISTS(LocaleLoader.getString("Unarmed.Ability.Lower"), LocaleLoader.getString("Unarmed.Ability.Ready")), - HOE(LocaleLoader.getString("Herbalism.Ability.Lower"), LocaleLoader.getString("Herbalism.Ability.Ready")), - PICKAXE(LocaleLoader.getString("Mining.Ability.Lower"), LocaleLoader.getString("Mining.Ability.Ready")), - SHOVEL(LocaleLoader.getString("Excavation.Ability.Lower"), LocaleLoader.getString("Excavation.Ability.Ready")), - SWORD(LocaleLoader.getString("Swords.Ability.Lower"), LocaleLoader.getString("Swords.Ability.Ready")); + AXE("Axes.Ability.Lower", "Axes.Ability.Ready"), + FISTS("Unarmed.Ability.Lower", "Unarmed.Ability.Ready"), + HOE("Herbalism.Ability.Lower", "Herbalism.Ability.Ready"), + PICKAXE("Mining.Ability.Lower", "Mining.Ability.Ready"), + SHOVEL("Excavation.Ability.Lower", "Excavation.Ability.Ready"), + SWORD("Swords.Ability.Lower", "Swords.Ability.Ready"); private String lowerTool; private String raiseTool; diff --git a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java index 070e34e2d..7b72abe16 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java @@ -1,6 +1,8 @@ package com.gmail.nossr50.events.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -12,13 +14,16 @@ import org.bukkit.event.player.PlayerEvent; public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable { private boolean isCancelled; private static final HandlerList handlers = new HandlerList(); - protected String notificationMessage; + protected ChatMessageType chatMessageType; + + protected TextComponent notificationTextComponent; protected final NotificationType notificationType; - public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, String notificationMessage) { + public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, net.md_5.bungee.api.chat.TextComponent notificationTextComponent, ChatMessageType chatMessageType) { super(who); this.notificationType = notificationType; - this.notificationMessage = notificationMessage; + this.notificationTextComponent = notificationTextComponent; + this.chatMessageType = chatMessageType; isCancelled = false; } @@ -26,6 +31,22 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell * Getters & Setters */ + public TextComponent getNotificationTextComponent() { + return notificationTextComponent; + } + + public void setNotificationTextComponent(TextComponent notificationTextComponent) { + this.notificationTextComponent = notificationTextComponent; + } + + public ChatMessageType getChatMessageType() { + return chatMessageType; + } + + public void setChatMessageType(ChatMessageType chatMessageType) { + this.chatMessageType = chatMessageType; + } + /** * The notification type for this event * @return this event's notification type @@ -34,22 +55,6 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell return notificationType; } - /** - * The message delivered to players by this notification - * @return the message that will be delivered to the player - */ - public String getNotificationMessage() { - return notificationMessage; - } - - /** - * Change the notification message - * @param newMessage the new replacement message - */ - public void setNotificationMessage(String newMessage) { - notificationMessage = newMessage; - } - /* * Custom Event Boilerplate */ diff --git a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java index 60d25bd9a..24dfbd516 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java +++ b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java @@ -2,6 +2,8 @@ package com.gmail.nossr50.listeners; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.interactions.NotificationType; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.PrimarySkill; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction; @@ -10,10 +12,12 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.TextComponentFactory; import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.Event; +import java.awt.*; import java.util.ArrayList; import java.util.HashMap; @@ -91,25 +95,61 @@ public class InteractionManager { * This does this by sending out an event so other plugins can cancel it * @param player target player * @param notificationType notifications defined type - * @param localeKey the locale key for the notifications defined message + * @param key the locale key for the notifications defined message */ - public static void sendPlayerInformation(Player player, NotificationType notificationType, String localeKey) + public static void sendPlayerInformation(Player player, NotificationType notificationType, String key) { + + ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; + + TextComponent message = TextComponentFactory.getNotificationTextComponentFromLocale(key, notificationType); + McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message); + + sendNotification(player, customEvent); + } + + public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values) + { + + ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; + + TextComponent message = TextComponentFactory.getNotificationTextComponentFromLocale(key, notificationType, values); + McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message); + + sendNotification(player, customEvent); + } + + private static void sendNotification(Player player, McMMOPlayerNotificationEvent customEvent) { + if (customEvent.isCancelled()) + return; + + player.spigot().sendMessage(customEvent.getChatMessageType(), customEvent.getNotificationTextComponent()); + } + + private static McMMOPlayerNotificationEvent checkNotificationEvent(Player player, NotificationType notificationType, ChatMessageType destination, TextComponent message) { //Init event - McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player, notificationType, LocaleLoader.getString(localeKey)); + McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player, + notificationType, message, destination); + //Call event Bukkit.getServer().getPluginManager().callEvent(customEvent); + return customEvent; + } - //Check to see if our custom event is cancelled - if(!customEvent.isCancelled()) - { - if(AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType)) - { - player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponentFactory.getNotificationTextComponent(customEvent.getNotificationMessage(), notificationType)); - } else { - player.spigot().sendMessage(ChatMessageType.SYSTEM, TextComponentFactory.getNotificationTextComponent(customEvent.getNotificationMessage(), notificationType)); - } - } + /** + * Handles sending level up notifications to a mcMMOPlayer + * @param mcMMOPlayer target mcMMOPlayer + * @param skillName skill that leveled up + * @param newLevel new level of that skill + */ + public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkill skillName, int newLevel) + { + ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; + + TextComponent levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(mcMMOPlayer, skillName, newLevel); + McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(mcMMOPlayer.getPlayer(), NotificationType.LEVEL_UP_MESSAGE, destination, levelUpTextComponent); + + sendNotification(mcMMOPlayer.getPlayer(), customEvent); } /** diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java index 6b9b1bfa0..a5479f5ba 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.runnables.skills; +import com.gmail.nossr50.datatypes.interactions.NotificationType; +import com.gmail.nossr50.listeners.InteractionManager; import org.bukkit.scheduler.BukkitRunnable; import com.gmail.nossr50.config.Config; @@ -24,7 +26,7 @@ public class ToolLowerTask extends BukkitRunnable { mcMMOPlayer.setToolPreparationMode(tool, false); if (Config.getInstance().getAbilityMessagesEnabled()) { - mcMMOPlayer.getPlayer().sendMessage(tool.getLowerTool()); + InteractionManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool()); } } } diff --git a/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java b/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java index 9ca027e39..8877b74d5 100644 --- a/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java +++ b/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java @@ -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; diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ObjectiveType.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ObjectiveType.java new file mode 100644 index 000000000..5f53bd37a --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ObjectiveType.java @@ -0,0 +1,6 @@ +package com.gmail.nossr50.util.scoreboards; + +public enum ObjectiveType { + SIDEBAR, + POWER +} diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 29260f0f3..e0d3ba329 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -32,8 +32,9 @@ import com.google.common.collect.Lists; public class ScoreboardManager { static final Map PLAYER_SCOREBOARDS = new HashMap(); + // 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); } diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java index df6ff04f3..79f46d763 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java @@ -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); diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index def85ed84..70587b447 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -671,30 +671,22 @@ Skills: Style: JSON: Notification: - LevelUps: - Bold: true - Italics: false - Underline: false - ToolReady: - Bold: false - Italics: true - Underline: false - SubSkillInteraction: - Bold: false - Italics: true - Underline: false - SubSkillUnlocked: - Bold: true - Italics: false - Underline: false - SuperAbilityInteraction: - Bold: true - Italics: false - Underline: false - ExperienceGain: - Bold: true - Italics: false - Underline: false + LevelRequirementNotMet: + Color: RED + AbilityCoolDown: + Color: RED + LevelUps: + Color: GOLD + ToolReady: + Color: GREEN + SubSkillInteraction: + Color: YELLOW + SubSkillUnlocked: + Color: PURPLE + SuperAbilityInteraction: + Color: DARK_AQUA + ExperienceGain: + Color: WHITE Hover: Details: Header: diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index a54cf8a6a..eca2d6a90 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -25,6 +25,21 @@ JSON.JWrapper.Target.Mobs=Mobs JSON.JWrapper.Perks.Header=[[GOLD]]Lucky Perks JSON.JWrapper.Perks.Lucky={0}% Better Odds JSON.Hover.Tips=Tips +JSON.Acrobatics=Acrobatics +JSON.Alchemy=Alchemy +JSON.Archery=Archery +JSON.Axes=Axes +JSON.Excavation=Excavation +JSON.Fishing=Fishing +JSON.Herbalism=Herbalism +JSON.Mining=Mining +JSON.Repair=Repair +JSON.Salvage=Salvage +JSON.Swords=Swords +JSON.Taming=Taming +JSON.Unarmed=Unarmed +JSON.Woodcutting=Woodcutting +JSON.LevelUp=increased to #This is the message sent to players when an ability is activated JSON.Notification.SuperAbility={0}