Most things that print to your chat will now print to action bar

This commit is contained in:
nossr50 2019-01-11 07:11:17 -08:00
parent 19c38f0cb1
commit d141a28747
13 changed files with 70 additions and 28 deletions

View File

@ -47,6 +47,7 @@ Version 2.1.0
= (MySQL) When converting from MySQL to flatfile mcMMO will now properly include all users in the conversion process = (MySQL) When converting from MySQL to flatfile mcMMO will now properly include all users in the conversion process
+ (Party) Parties can now have size limits (configurable in config.yml), party size is unlimited by default + (Party) Parties can now have size limits (configurable in config.yml), party size is unlimited by default
! (Party) Party member list will only include members of the party that you can see (aren't vanished) ! (Party) Party member list will only include members of the party that you can see (aren't vanished)
! (Skills) Fixed an edge case bug where Blast Mining wouldn't inform the player that it was on cooldown
! (Skills) mcMMO skills will now be on a scale from 1-100 instead of 0-1000 (for existing mcMMO installs this is opt-in and off by default) ! (Skills) mcMMO skills will now be on a scale from 1-100 instead of 0-1000 (for existing mcMMO installs this is opt-in and off by default)
! (Skills) Skill Super Powers (Tree Feller, etc...) will now require level 10+ to use ! (Skills) Skill Super Powers (Tree Feller, etc...) will now require level 10+ to use
! (Skills) Acrobatics' Roll exploit detection was tweaked to still allow for Roll to trigger even if it rewards no XP ! (Skills) Acrobatics' Roll exploit detection was tweaked to still allow for Roll to trigger even if it rewards no XP

View File

@ -10,8 +10,11 @@ public enum NotificationType {
SUBSKILL_MESSAGE("SubSkillInteraction"), SUBSKILL_MESSAGE("SubSkillInteraction"),
TOOL("ToolReady"), TOOL("ToolReady"),
UNSKILLED("LevelRequirementNotMet"), UNSKILLED("LevelRequirementNotMet"),
ABILITY_OFF("AbilityOff"),
ABILITY_COOLDOWN("AbilityCoolDown"), ABILITY_COOLDOWN("AbilityCoolDown"),
SUPER_ABILITY("SuperAbilityInteraction"); ABILITY_REFRESHED("AbilityRefreshed"),
SUPER_ABILITY("SuperAbilityInteraction"),
SUPER_ABILITY_ALERT_OTHERS("SuperAbilityAlertOthers");
final String niceName; final String niceName;

View File

@ -772,10 +772,11 @@ public class McMMOPlayer {
ParticleEffectUtils.playAbilityEnabledEffect(player); ParticleEffectUtils.playAbilityEnabledEffect(player);
if (useChatNotifications()) { if (useChatNotifications()) {
player.sendMessage(ability.getAbilityOn()); InteractionManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, ability.getAbilityOn());
//player.sendMessage(ability.getAbilityOn());
} }
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player)); SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayer());
// Enable the ability // Enable the ability
profile.setAbilityDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); profile.setAbilityDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));

View File

@ -94,23 +94,23 @@ public enum SuperAbility {
} }
public String getAbilityOn() { public String getAbilityOn() {
return LocaleLoader.getString(this.abilityOn); return abilityOn;
} }
public String getAbilityOff() { public String getAbilityOff() {
return LocaleLoader.getString(this.abilityOff); return abilityOff;
} }
public String getAbilityPlayer(Player player) { public String getAbilityPlayer() {
return LocaleLoader.getString(this.abilityPlayer, player.getName()); return abilityPlayer;
} }
public String getAbilityPlayerOff(Player player) { public String getAbilityPlayerOff() {
return LocaleLoader.getString(this.abilityPlayerOff, player.getName()); return abilityPlayerOff;
} }
public String getAbilityRefresh() { public String getAbilityRefresh() {
return LocaleLoader.getString(this.abilityRefresh); return abilityRefresh;
} }
public String getName() { public String getName() {

View File

@ -10,14 +10,15 @@ import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction;
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
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.util.Misc;
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 net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
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;
@ -108,12 +109,21 @@ public class InteractionManager {
sendNotification(player, customEvent); sendNotification(player, customEvent);
} }
public static void sendOtherPlayersSkillInfo(Player source, NotificationType notificationType, String key, String... values)
{
Location location = source.getLocation();
for (Player otherPlayer : source.getWorld().getPlayers()) {
if (otherPlayer != source && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
sendPlayerInformation(otherPlayer, notificationType, key, values);
}
}
}
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values) public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
{ {
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
TextComponent message = TextComponentFactory.getNotificationTextComponentFromLocale(key, notificationType, values); TextComponent message = TextComponentFactory.getNotificationMultipleValues(key, notificationType, values);
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message); McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message);
sendNotification(player, customEvent); sendNotification(player, customEvent);

View File

@ -1,6 +1,8 @@
package com.gmail.nossr50.runnables.skills; package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.skills.SuperAbility; import com.gmail.nossr50.datatypes.skills.SuperAbility;
import com.gmail.nossr50.listeners.InteractionManager;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -21,6 +23,8 @@ public class AbilityCooldownTask extends BukkitRunnable {
} }
mcMMOPlayer.setAbilityInformed(ability, true); mcMMOPlayer.setAbilityInformed(ability, true);
mcMMOPlayer.getPlayer().sendMessage(ability.getAbilityRefresh());
InteractionManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, ability.getAbilityRefresh());
//mcMMOPlayer.getPlayer().sendMessage(ability.getAbilityRefresh());
} }
} }

View File

@ -1,6 +1,8 @@
package com.gmail.nossr50.runnables.skills; package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.skills.SuperAbility; import com.gmail.nossr50.datatypes.skills.SuperAbility;
import com.gmail.nossr50.listeners.InteractionManager;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -56,10 +58,12 @@ public class AbilityDisableTask extends BukkitRunnable {
ParticleEffectUtils.playAbilityDisabledEffect(player); ParticleEffectUtils.playAbilityDisabledEffect(player);
if (mcMMOPlayer.useChatNotifications()) { if (mcMMOPlayer.useChatNotifications()) {
player.sendMessage(ability.getAbilityOff()); //player.sendMessage(ability.getAbilityOff());
InteractionManager.sendPlayerInformation(player, NotificationType.ABILITY_OFF, ability.getAbilityOff());
} }
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff());
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR); new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
} }

View File

@ -1,11 +1,13 @@
package com.gmail.nossr50.skills.mining; package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbility; 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.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
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.runnables.skills.AbilityCooldownTask; import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
@ -97,14 +99,16 @@ public class MiningManager extends SkillManager {
Player player = getPlayer(); Player player = getPlayer();
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE); Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
if (targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true) || !blastMiningCooldownOver()) { //Blast mining cooldown check needs to be first so the player can be messaged
if (!blastMiningCooldownOver() || targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true)) {
return; return;
} }
TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class); TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class);
SkillUtils.sendSkillMessage(player, SuperAbility.BLAST_MINING.getAbilityPlayer(player)); //SkillUtils.sendSkillMessage(player, SuperAbility.BLAST_MINING.getAbilityPlayer(player));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom")); InteractionManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom");
//player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
tnt.setMetadata(mcMMO.tntMetadataKey, mcMMOPlayer.getPlayerMetadata()); tnt.setMetadata(mcMMO.tntMetadataKey, mcMMOPlayer.getPlayerMetadata());
tnt.setFuseTicks(0); tnt.setFuseTicks(0);
@ -290,7 +294,8 @@ public class MiningManager extends SkillManager {
int timeRemaining = mcMMOPlayer.calculateTimeRemaining(SuperAbility.BLAST_MINING); int timeRemaining = mcMMOPlayer.calculateTimeRemaining(SuperAbility.BLAST_MINING);
if (timeRemaining > 0) { if (timeRemaining > 0) {
getPlayer().sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining)); //getPlayer().sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
InteractionManager.sendPlayerInformation(getPlayer(), NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf("timeRemaining"));
return false; return false;
} }

View File

@ -32,10 +32,6 @@ public class StringUtils {
public static String getPrettyAbilityString(SuperAbility ability) { public static String getPrettyAbilityString(SuperAbility ability) {
return createPrettyString(ability.toString()); return createPrettyString(ability.toString());
} }
public static String getPrettyTreeSpeciesString(TreeSpecies species) {
return createPrettyString(species.toString());
}
public static String getWildcardConfigBlockDataString(BlockData data) { public static String getWildcardConfigBlockDataString(BlockData data) {
return getWildcardConfigMaterialString(data.getMaterial()); return getWildcardConfigMaterialString(data.getMaterial());

View File

@ -34,10 +34,17 @@ public class TextComponentFactory {
* @param values * @param values
* @return * @return
*/ */
public static TextComponent getNotificationTextComponentFromLocale(String localeKey, NotificationType notificationType, String... values) public static TextComponent getNotificationMultipleValues(String localeKey, NotificationType notificationType, String... values)
{ {
//TODO: Make this colored //TODO: Make this colored
return new TextComponent(LocaleLoader.getString(localeKey, values)); String preColoredString = LocaleLoader.getString(localeKey, values);
/*for(int x = 0; x < values.length; x++)
{
}*/
return new TextComponent(preColoredString);
} }
public static TextComponent getNotificationTextComponentFromLocale(String localeKey, NotificationType notificationType) public static TextComponent getNotificationTextComponentFromLocale(String localeKey, NotificationType notificationType)
@ -573,6 +580,7 @@ public class TextComponentFactory {
{ {
if(Permissions.isSubSkillEnabled(player, subSkillType)) if(Permissions.isSubSkillEnabled(player, subSkillType))
{ {
if(InteractionManager.getInteractRegister().get(subSkillType.getNiceNameNoSpaces(subSkillType)) == null)
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, subSkillType)); textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, subSkillType));
} }
} }

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.util.skills;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbility; import com.gmail.nossr50.datatypes.skills.SuperAbility;
@ -12,6 +13,7 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.RandomChance; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.RandomChance;
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillWeightedActivationCheckEvent; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillWeightedActivationCheckEvent;
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.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
@ -31,6 +33,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.awt.*;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -130,12 +133,12 @@ public class SkillUtils {
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? PrimarySkill.getSkill(skillName) != null : isLocalizedSkill(skillName); return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? PrimarySkill.getSkill(skillName) != null : isLocalizedSkill(skillName);
} }
public static void sendSkillMessage(Player player, String message) { public static void sendSkillMessage(Player player, NotificationType notificationType, String key) {
Location location = player.getLocation(); Location location = player.getLocation();
for (Player otherPlayer : player.getWorld().getPlayers()) { for (Player otherPlayer : player.getWorld().getPlayers()) {
if (otherPlayer != player && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { if (otherPlayer != player && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
otherPlayer.sendMessage(message); InteractionManager.sendOtherPlayersSkillInfo(player, notificationType, key);
} }
} }
} }

View File

@ -671,6 +671,8 @@ Skills:
Style: Style:
JSON: JSON:
Notification: Notification:
AbilityOff:
Color: GRAY
LevelRequirementNotMet: LevelRequirementNotMet:
Color: RED Color: RED
AbilityCoolDown: AbilityCoolDown:
@ -685,6 +687,10 @@ Style:
Color: PURPLE Color: PURPLE
SuperAbilityInteraction: SuperAbilityInteraction:
Color: DARK_AQUA Color: DARK_AQUA
SuperAbilityAlertOthers:
Color:
Party: GREEN
Others: DARK_RED
ExperienceGain: ExperienceGain:
Color: WHITE Color: WHITE
Hover: Hover:

View File

@ -241,6 +241,7 @@ Mining.Skills.SuperBreaker.Refresh=[[GREEN]]Your [[YELLOW]]Super Breaker [[GREEN
Mining.Skillup=[[YELLOW]]Mining skill increased by {0}. Total ({1}) Mining.Skillup=[[YELLOW]]Mining skill increased by {0}. Total ({1})
#Blast Mining #Blast Mining
Mining.Blast.Boom=[[GRAY]]**BOOM** Mining.Blast.Boom=[[GRAY]]**BOOM**
Mining.Blast.Cooldown=
Mining.Blast.Effect=+{0} ore yield, -{1} debris yield, {2}x drops Mining.Blast.Effect=+{0} ore yield, -{1} debris yield, {2}x drops
Mining.Blast.Radius.Increase=[[RED]]Blast Radius Increase: [[YELLOW]]+{0} Mining.Blast.Radius.Increase=[[RED]]Blast Radius Increase: [[YELLOW]]+{0}
Mining.Blast.Rank=[[RED]]Blast Mining: [[YELLOW]] Rank {0}/{1} [[GRAY]]({2}) Mining.Blast.Rank=[[RED]]Blast Mining: [[YELLOW]] Rank {0}/{1} [[GRAY]]({2})