From fd47d7780077f879c1046487013f30bac80cad0a Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 19 Feb 2013 13:25:59 -0500 Subject: [PATCH] Add chat toggles for the events we have particle effects for. --- .../nossr50/skills/archery/DazeEventHandler.java | 13 +++++++++++-- .../nossr50/skills/swords/BleedEventHandler.java | 16 ++++++++++++---- .../nossr50/skills/utilities/SkillTools.java | 11 +++++++++-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/archery/DazeEventHandler.java b/src/main/java/com/gmail/nossr50/skills/archery/DazeEventHandler.java index 72f554890..43b04a1d7 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/DazeEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/DazeEventHandler.java @@ -6,12 +6,15 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Users; public class DazeEventHandler { private ArcheryManager manager; + private McMMOPlayer mcMMOPlayer; private EntityDamageEvent event; private Player defender; @@ -21,6 +24,7 @@ public class DazeEventHandler { protected DazeEventHandler (ArcheryManager manager, EntityDamageEvent event, Player defender) { this.manager = manager; + this.mcMMOPlayer = manager.getMcMMOPlayer(); this.event = event; this.defender = defender; @@ -48,7 +52,12 @@ public class DazeEventHandler { } protected void sendAbilityMessages() { - defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy")); - manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed")); + if (Users.getPlayer(defender).getProfile().useChatNotifications()) { + defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy")); + } + + if (mcMMOPlayer.getProfile().useChatNotifications()) { + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed")); + } } } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/BleedEventHandler.java b/src/main/java/com/gmail/nossr50/skills/swords/BleedEventHandler.java index 332e98b8d..36fccd9ca 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/BleedEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/BleedEventHandler.java @@ -3,18 +3,20 @@ package com.gmail.nossr50.skills.swords; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.runnables.BleedTimer; import com.gmail.nossr50.skills.utilities.SkillTools; +import com.gmail.nossr50.util.Users; public class BleedEventHandler { - private SwordsManager manager; + private McMMOPlayer mcMMOPlayer; private int skillLevel; private LivingEntity defender; protected int skillModifier; protected BleedEventHandler(SwordsManager manager, LivingEntity defender) { - this.manager = manager; + this.mcMMOPlayer = manager.getMcMMOPlayer(); this.skillLevel = manager.getSkillLevel(); this.defender = defender; @@ -39,10 +41,16 @@ public class BleedEventHandler { } protected void sendAbilityMessages() { - manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); + if (mcMMOPlayer.getProfile().useChatNotifications()) { + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); + } if (defender instanceof Player) { - ((Player) defender).sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started")); + Player defendingPlayer = (Player) defender; + + if (Users.getPlayer(defendingPlayer).getProfile().useChatNotifications()) { + defendingPlayer.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started")); + } } } } diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java index a41205bcc..08245c1fb 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java @@ -200,7 +200,10 @@ public class SkillTools { profile.setAbilityMode(ability, false); profile.setAbilityInformed(ability, false); player.playEffect(player.getEyeLocation(), Effect.POTION_BREAK, new Potion(PotionType.STRENGTH)); - player.sendMessage(ability.getAbilityOff()); + + if (profile.useChatNotifications()) { + player.sendMessage(ability.getAbilityOff()); + } sendSkillMessage(player, ability.getAbilityPlayerOff(player)); } @@ -392,7 +395,11 @@ public class SkillTools { int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / abilityLengthIncreaseLevel), ability.getMaxTicks()); player.playEffect(player.getEyeLocation(), Effect.POTION_BREAK, new Potion(PotionType.POISON)); - player.sendMessage(ability.getAbilityOn()); + + if (profile.useChatNotifications()) { + player.sendMessage(ability.getAbilityOn()); + } + SkillTools.sendSkillMessage(player, ability.getAbilityPlayer(player)); profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));