mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Players need to have unique objectives
This commit is contained in:
parent
adc83d29a7
commit
f11b98c29d
@ -15,6 +15,9 @@ Version 2.1.0
|
|||||||
+ Added links to mcMMO related websites to various commands
|
+ Added links to mcMMO related websites to various commands
|
||||||
+ Certain elements of mcMMO's UI have been restyled
|
+ Certain elements of mcMMO's UI have been restyled
|
||||||
+ Added the tagline "Overhaul Era" to various locations until 3.0.0 comes out
|
+ 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) Added option to disable the new URL links to config.yml
|
||||||
+ (Config) New config file added coreskills.yml
|
+ (Config) New config file added coreskills.yml
|
||||||
+ (Config) Added rank settings for the new Woodcutting skill
|
+ (Config) Added rank settings for the new Woodcutting skill
|
||||||
|
@ -711,7 +711,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
case SUBSKILL_UNLOCKED:
|
case SUBSKILL_UNLOCKED:
|
||||||
key = "SubSkillUnlocked";
|
key = "SubSkillUnlocked";
|
||||||
break;
|
break;
|
||||||
case TOOL_READY:
|
case TOOL:
|
||||||
key = "ToolReady";
|
key = "ToolReady";
|
||||||
break;
|
break;
|
||||||
case SUPER_ABILITY:
|
case SUPER_ABILITY:
|
||||||
@ -781,16 +781,25 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
return config.getBoolean("Style.JSON.Hover.Details.Description.Underlined");
|
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) {
|
private ChatColor getChatColorFromKey(String keyLocation) {
|
||||||
String colorName = LocaleLoader.getString(keyLocation);
|
String colorName = LocaleLoader.getString(keyLocation);
|
||||||
|
|
||||||
|
return getChatColor(colorName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChatColor getChatColor(String configColor) {
|
||||||
for (ChatColor chatColor : ChatColor.values()) {
|
for (ChatColor chatColor : ChatColor.values()) {
|
||||||
if (colorName.equalsIgnoreCase(chatColor.toString()))
|
if (configColor.equalsIgnoreCase(chatColor.getName()))
|
||||||
return chatColor;
|
return chatColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Invalid Color
|
//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;
|
return ChatColor.WHITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,23 @@ package com.gmail.nossr50.datatypes.interactions;
|
|||||||
* This class helps define the types of information interactions we will have with players
|
* This class helps define the types of information interactions we will have with players
|
||||||
*/
|
*/
|
||||||
public enum NotificationType {
|
public enum NotificationType {
|
||||||
XP_GAIN,
|
XP_GAIN("ExperienceGain"),
|
||||||
SUBSKILL_UNLOCKED,
|
SUBSKILL_UNLOCKED("SubSkillUnlocked"),
|
||||||
LEVEL_UP_MESSAGE,
|
LEVEL_UP_MESSAGE("LevelUps"),
|
||||||
SUBSKILL_MESSAGE,
|
SUBSKILL_MESSAGE("SubSkillInteraction"),
|
||||||
TOOL_READY,
|
TOOL("ToolReady"),
|
||||||
SUPER_ABILITY
|
UNSKILLED("LevelRequirementNotMet"),
|
||||||
|
ABILITY_COOLDOWN("AbilityCoolDown"),
|
||||||
|
SUPER_ABILITY("SuperAbilityInteraction");
|
||||||
|
|
||||||
|
final String niceName;
|
||||||
|
|
||||||
|
NotificationType(String niceName)
|
||||||
|
{
|
||||||
|
this.niceName = niceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return niceName;
|
||||||
|
}}
|
||||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
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.mods.CustomTool;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
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.PrimarySkill;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
|
import com.gmail.nossr50.listeners.InteractionManager;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
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.EventUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
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.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();
|
ToolType tool = skill.getTool();
|
||||||
SuperAbility ability = skill.getAbility();
|
SuperAbility ability = skill.getAbility();
|
||||||
|
|
||||||
setToolPreparationMode(tool, false);
|
|
||||||
|
|
||||||
if (getAbilityMode(ability)) {
|
if (getAbilityMode(ability)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -785,6 +785,7 @@ public class McMMOPlayer {
|
|||||||
SkillUtils.handleAbilitySpeedIncrease(player);
|
SkillUtils.handleAbilitySpeedIncrease(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setToolPreparationMode(tool, false);
|
||||||
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
|
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,6 +812,7 @@ public class McMMOPlayer {
|
|||||||
|
|
||||||
SuperAbility ability = skill.getAbility();
|
SuperAbility ability = skill.getAbility();
|
||||||
ToolType tool = skill.getTool();
|
ToolType tool = skill.getTool();
|
||||||
|
setToolPreparationMode(tool, true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Woodcutting & Axes need to be treated differently.
|
* Woodcutting & Axes need to be treated differently.
|
||||||
@ -821,16 +823,15 @@ public class McMMOPlayer {
|
|||||||
int timeRemaining = calculateTimeRemaining(ability);
|
int timeRemaining = calculateTimeRemaining(ability);
|
||||||
|
|
||||||
if (!getAbilityMode(ability) && timeRemaining > 0) {
|
if (!getAbilityMode(ability) && timeRemaining > 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
InteractionManager.sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
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);
|
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,12 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
|
|
||||||
public enum ToolType {
|
public enum ToolType {
|
||||||
AXE(LocaleLoader.getString("Axes.Ability.Lower"), LocaleLoader.getString("Axes.Ability.Ready")),
|
AXE("Axes.Ability.Lower", "Axes.Ability.Ready"),
|
||||||
FISTS(LocaleLoader.getString("Unarmed.Ability.Lower"), LocaleLoader.getString("Unarmed.Ability.Ready")),
|
FISTS("Unarmed.Ability.Lower", "Unarmed.Ability.Ready"),
|
||||||
HOE(LocaleLoader.getString("Herbalism.Ability.Lower"), LocaleLoader.getString("Herbalism.Ability.Ready")),
|
HOE("Herbalism.Ability.Lower", "Herbalism.Ability.Ready"),
|
||||||
PICKAXE(LocaleLoader.getString("Mining.Ability.Lower"), LocaleLoader.getString("Mining.Ability.Ready")),
|
PICKAXE("Mining.Ability.Lower", "Mining.Ability.Ready"),
|
||||||
SHOVEL(LocaleLoader.getString("Excavation.Ability.Lower"), LocaleLoader.getString("Excavation.Ability.Ready")),
|
SHOVEL("Excavation.Ability.Lower", "Excavation.Ability.Ready"),
|
||||||
SWORD(LocaleLoader.getString("Swords.Ability.Lower"), LocaleLoader.getString("Swords.Ability.Ready"));
|
SWORD("Swords.Ability.Lower", "Swords.Ability.Ready");
|
||||||
|
|
||||||
private String lowerTool;
|
private String lowerTool;
|
||||||
private String raiseTool;
|
private String raiseTool;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.gmail.nossr50.events.skills;
|
package com.gmail.nossr50.events.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
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.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@ -12,13 +14,16 @@ import org.bukkit.event.player.PlayerEvent;
|
|||||||
public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable {
|
public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable {
|
||||||
private boolean isCancelled;
|
private boolean isCancelled;
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
protected String notificationMessage;
|
protected ChatMessageType chatMessageType;
|
||||||
|
|
||||||
|
protected TextComponent notificationTextComponent;
|
||||||
protected final NotificationType notificationType;
|
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);
|
super(who);
|
||||||
this.notificationType = notificationType;
|
this.notificationType = notificationType;
|
||||||
this.notificationMessage = notificationMessage;
|
this.notificationTextComponent = notificationTextComponent;
|
||||||
|
this.chatMessageType = chatMessageType;
|
||||||
isCancelled = false;
|
isCancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,6 +31,22 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell
|
|||||||
* Getters & Setters
|
* 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
|
* The notification type for this event
|
||||||
* @return this event's notification type
|
* @return this event's notification type
|
||||||
@ -34,22 +55,6 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell
|
|||||||
return notificationType;
|
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
|
* Custom Event Boilerplate
|
||||||
*/
|
*/
|
||||||
|
@ -2,6 +2,8 @@ package com.gmail.nossr50.listeners;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
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.AbstractSubSkill;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction;
|
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.mcMMO;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.TextComponentFactory;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
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
|
* This does this by sending out an event so other plugins can cancel it
|
||||||
* @param player target player
|
* @param player target player
|
||||||
* @param notificationType notifications defined type
|
* @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
|
//Init event
|
||||||
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player, notificationType, LocaleLoader.getString(localeKey));
|
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player,
|
||||||
|
notificationType, message, destination);
|
||||||
|
|
||||||
//Call event
|
//Call event
|
||||||
Bukkit.getServer().getPluginManager().callEvent(customEvent);
|
Bukkit.getServer().getPluginManager().callEvent(customEvent);
|
||||||
|
return customEvent;
|
||||||
|
}
|
||||||
|
|
||||||
//Check to see if our custom event is cancelled
|
/**
|
||||||
if(!customEvent.isCancelled())
|
* 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)
|
||||||
{
|
{
|
||||||
if(AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType))
|
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
|
||||||
{
|
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponentFactory.getNotificationTextComponent(customEvent.getNotificationMessage(), notificationType));
|
TextComponent levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(mcMMOPlayer, skillName, newLevel);
|
||||||
} else {
|
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(mcMMOPlayer.getPlayer(), NotificationType.LEVEL_UP_MESSAGE, destination, levelUpTextComponent);
|
||||||
player.spigot().sendMessage(ChatMessageType.SYSTEM, TextComponentFactory.getNotificationTextComponent(customEvent.getNotificationMessage(), notificationType));
|
|
||||||
}
|
sendNotification(mcMMOPlayer.getPlayer(), customEvent);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.runnables.skills;
|
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 org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
@ -24,7 +26,7 @@ public class ToolLowerTask extends BukkitRunnable {
|
|||||||
mcMMOPlayer.setToolPreparationMode(tool, false);
|
mcMMOPlayer.setToolPreparationMode(tool, false);
|
||||||
|
|
||||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
||||||
mcMMOPlayer.getPlayer().sendMessage(tool.getLowerTool());
|
InteractionManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.json.McMMOUrl;
|
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.PrimarySkill;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
@ -26,12 +27,68 @@ public class TextComponentFactory {
|
|||||||
|
|
||||||
public static BaseComponent[] webComponents;
|
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;
|
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) {
|
public static void sendPlayerUrlHeader(Player player) {
|
||||||
if(!Config.getInstance().getUrlLinksEnabled())
|
if(!Config.getInstance().getUrlLinksEnabled())
|
||||||
return;
|
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 {
|
public class ScoreboardManager {
|
||||||
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<String, ScoreboardWrapper>();
|
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<String, ScoreboardWrapper>();
|
||||||
|
|
||||||
|
|
||||||
// do not localize; these are internal identifiers
|
// 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 POWER_OBJECTIVE = "mcmmo_pwrlvl";
|
||||||
|
|
||||||
static final String HEADER_STATS = LocaleLoader.getString("Scoreboard.Header.PlayerStats");
|
static final String HEADER_STATS = LocaleLoader.getString("Scoreboard.Header.PlayerStats");
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.util.scoreboards;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -30,6 +31,7 @@ import org.apache.commons.lang.Validate;
|
|||||||
public class ScoreboardWrapper {
|
public class ScoreboardWrapper {
|
||||||
// Initialization variables
|
// Initialization variables
|
||||||
public final String playerName;
|
public final String playerName;
|
||||||
|
public final UUID playerUUID;
|
||||||
private final Scoreboard scoreboard;
|
private final Scoreboard scoreboard;
|
||||||
private boolean tippedKeep = false;
|
private boolean tippedKeep = false;
|
||||||
private boolean tippedClear = false;
|
private boolean tippedClear = false;
|
||||||
@ -46,12 +48,24 @@ public class ScoreboardWrapper {
|
|||||||
private PlayerProfile targetProfile = null;
|
private PlayerProfile targetProfile = null;
|
||||||
public int leaderboardPage = -1;
|
public int leaderboardPage = -1;
|
||||||
|
|
||||||
private ScoreboardWrapper(String playerName, Scoreboard scoreboard) {
|
private ScoreboardWrapper(Player player, Scoreboard scoreboard) {
|
||||||
this.playerName = playerName;
|
this.playerName = player.getName();
|
||||||
this.scoreboard = scoreboard;
|
this.scoreboard = scoreboard;
|
||||||
|
this.playerUUID = player.getUniqueId();
|
||||||
sidebarType = SidebarType.NONE;
|
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()) {
|
if (Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||||
powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
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) {
|
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;
|
public BukkitTask updateTask = null;
|
||||||
@ -372,7 +400,7 @@ public class ScoreboardWrapper {
|
|||||||
// Setup for after a board type change
|
// Setup for after a board type change
|
||||||
protected void loadObjective(String displayName) {
|
protected void loadObjective(String displayName) {
|
||||||
sidebarObjective.unregister();
|
sidebarObjective.unregister();
|
||||||
sidebarObjective = scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
sidebarObjective = scoreboard.registerNewObjective(getObjective(ObjectiveType.SIDEBAR), "dummy");
|
||||||
|
|
||||||
if (displayName.length() > 32) {
|
if (displayName.length() > 32) {
|
||||||
displayName = displayName.substring(0, 32);
|
displayName = displayName.substring(0, 32);
|
||||||
|
@ -671,30 +671,22 @@ Skills:
|
|||||||
Style:
|
Style:
|
||||||
JSON:
|
JSON:
|
||||||
Notification:
|
Notification:
|
||||||
|
LevelRequirementNotMet:
|
||||||
|
Color: RED
|
||||||
|
AbilityCoolDown:
|
||||||
|
Color: RED
|
||||||
LevelUps:
|
LevelUps:
|
||||||
Bold: true
|
Color: GOLD
|
||||||
Italics: false
|
|
||||||
Underline: false
|
|
||||||
ToolReady:
|
ToolReady:
|
||||||
Bold: false
|
Color: GREEN
|
||||||
Italics: true
|
|
||||||
Underline: false
|
|
||||||
SubSkillInteraction:
|
SubSkillInteraction:
|
||||||
Bold: false
|
Color: YELLOW
|
||||||
Italics: true
|
|
||||||
Underline: false
|
|
||||||
SubSkillUnlocked:
|
SubSkillUnlocked:
|
||||||
Bold: true
|
Color: PURPLE
|
||||||
Italics: false
|
|
||||||
Underline: false
|
|
||||||
SuperAbilityInteraction:
|
SuperAbilityInteraction:
|
||||||
Bold: true
|
Color: DARK_AQUA
|
||||||
Italics: false
|
|
||||||
Underline: false
|
|
||||||
ExperienceGain:
|
ExperienceGain:
|
||||||
Bold: true
|
Color: WHITE
|
||||||
Italics: false
|
|
||||||
Underline: false
|
|
||||||
Hover:
|
Hover:
|
||||||
Details:
|
Details:
|
||||||
Header:
|
Header:
|
||||||
|
@ -25,6 +25,21 @@ JSON.JWrapper.Target.Mobs=Mobs
|
|||||||
JSON.JWrapper.Perks.Header=[[GOLD]]Lucky Perks
|
JSON.JWrapper.Perks.Header=[[GOLD]]Lucky Perks
|
||||||
JSON.JWrapper.Perks.Lucky={0}% Better Odds
|
JSON.JWrapper.Perks.Lucky={0}% Better Odds
|
||||||
JSON.Hover.Tips=Tips
|
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
|
#This is the message sent to players when an ability is activated
|
||||||
JSON.Notification.SuperAbility={0}
|
JSON.Notification.SuperAbility={0}
|
||||||
|
Loading…
Reference in New Issue
Block a user