mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 01:03:44 +01:00 
			
		
		
		
	Add boolean for particle effects to ability events.
This commit is contained in:
		| @@ -777,7 +777,7 @@ public class McMMOPlayer { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (EventUtils.callPlayerAbilityActivateEvent(player, ability).isCancelled()) { |         if (!EventUtils.handlePlayerAbilityActivateEvent(player, ability)) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,22 +9,39 @@ import com.gmail.nossr50.datatypes.skills.SkillType; | |||||||
|  |  | ||||||
| public abstract class McMMOPlayerAbilityEvent extends PlayerEvent { | public abstract class McMMOPlayerAbilityEvent extends PlayerEvent { | ||||||
|     private AbilityType ability; |     private AbilityType ability; | ||||||
|  |     private boolean useParticleEffects; | ||||||
|  |  | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     protected McMMOPlayerAbilityEvent(Player player, SkillType skill) { |     protected McMMOPlayerAbilityEvent(Player player, SkillType skill) { | ||||||
|         super(player); |         super(player); | ||||||
|         ability = skill.getAbility(); |         ability = skill.getAbility(); | ||||||
|  |         useParticleEffects = true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected McMMOPlayerAbilityEvent(Player player, AbilityType ability) { |     protected McMMOPlayerAbilityEvent(Player player, AbilityType ability) { | ||||||
|         super(player); |         super(player); | ||||||
|         this.ability = ability; |         this.ability = ability; | ||||||
|  |         this.useParticleEffects = true; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     protected McMMOPlayerAbilityEvent(Player player, AbilityType ability, boolean useParticleEffects) { | ||||||
|  |         super(player); | ||||||
|  |         this.ability = ability; | ||||||
|  |         this.useParticleEffects = useParticleEffects; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public AbilityType getAbility() { |     public AbilityType getAbility() { | ||||||
|         return ability; |         return ability; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public boolean useParticleEffects() { | ||||||
|  |         return useParticleEffects; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void shouldUseParticleEffects(boolean useParticleEffects) { | ||||||
|  |         this.useParticleEffects = useParticleEffects; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** Rest of file is required boilerplate for custom events **/ |     /** Rest of file is required boilerplate for custom events **/ | ||||||
|     private static final HandlerList handlers = new HandlerList(); |     private static final HandlerList handlers = new HandlerList(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; | |||||||
| import com.gmail.nossr50.datatypes.skills.AbilityType; | import com.gmail.nossr50.datatypes.skills.AbilityType; | ||||||
| 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.skills.ParticleEffectUtils; |  | ||||||
| import com.gmail.nossr50.util.skills.PerksUtils; | import com.gmail.nossr50.util.skills.PerksUtils; | ||||||
| import com.gmail.nossr50.util.skills.SkillUtils; | import com.gmail.nossr50.util.skills.SkillUtils; | ||||||
|  |  | ||||||
| @@ -46,18 +45,11 @@ public class AbilityDisableTask extends BukkitRunnable { | |||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         EventUtils.callAbilityDeactivateEvent(player, ability); |         EventUtils.handleAbilityDeactivateEvent(player, ability); | ||||||
|  |  | ||||||
|         mcMMOPlayer.setAbilityMode(ability, false); |         mcMMOPlayer.setAbilityMode(ability, false); | ||||||
|         mcMMOPlayer.setAbilityInformed(ability, false); |         mcMMOPlayer.setAbilityInformed(ability, false); | ||||||
|  |  | ||||||
|         ParticleEffectUtils.playAbilityDisabledEffect(player); |  | ||||||
|  |  | ||||||
|         if (mcMMOPlayer.useChatNotifications()) { |  | ||||||
|             player.sendMessage(ability.getAbilityOff()); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player)); |  | ||||||
|         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); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -35,13 +35,29 @@ import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; | |||||||
| import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent; | import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent; | ||||||
| import com.gmail.nossr50.locale.LocaleLoader; | import com.gmail.nossr50.locale.LocaleLoader; | ||||||
| import com.gmail.nossr50.util.player.UserManager; | import com.gmail.nossr50.util.player.UserManager; | ||||||
|  | import com.gmail.nossr50.util.skills.ParticleEffectUtils; | ||||||
|  | import com.gmail.nossr50.util.skills.SkillUtils; | ||||||
|  |  | ||||||
| public class EventUtils { | public class EventUtils { | ||||||
|     public static McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, AbilityType ability) { |     public static boolean handlePlayerAbilityActivateEvent(Player player, AbilityType ability) { | ||||||
|         McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, ability); |         McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, ability); | ||||||
|         mcMMO.p.getServer().getPluginManager().callEvent(event); |         mcMMO.p.getServer().getPluginManager().callEvent(event); | ||||||
|  |  | ||||||
|         return event; |         boolean isCancelled = event.isCancelled(); | ||||||
|  |  | ||||||
|  |         if (!isCancelled) { | ||||||
|  |             if (event.useParticleEffects()) { | ||||||
|  |                 ParticleEffectUtils.playAbilityEnabledEffect(player); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             if (UserManager.getPlayer(player).useChatNotifications()) { | ||||||
|  |                 player.sendMessage(ability.getAbilityOn()); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return !isCancelled; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static FakePlayerAnimationEvent callFakeArmSwingEvent(Player player) { |     public static FakePlayerAnimationEvent callFakeArmSwingEvent(Player player) { | ||||||
| @@ -124,11 +140,19 @@ public class EventUtils { | |||||||
|         return !isCancelled; |         return !isCancelled; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static McMMOPlayerAbilityDeactivateEvent callAbilityDeactivateEvent(Player player, AbilityType ability) { |     public static void handleAbilityDeactivateEvent(Player player, AbilityType ability) { | ||||||
|         McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, ability); |         McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, ability); | ||||||
|         mcMMO.p.getServer().getPluginManager().callEvent(event); |         mcMMO.p.getServer().getPluginManager().callEvent(event); | ||||||
|  |  | ||||||
|         return event; |         if (event.useParticleEffects()) { | ||||||
|  |             ParticleEffectUtils.playAbilityDisabledEffect(player); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (UserManager.getPlayer(player).useChatNotifications()) { | ||||||
|  |             player.sendMessage(ability.getAbilityOff()); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static McMMOPlayerFishingTreasureEvent callFishingTreasureEvent(Player player, ItemStack treasureDrop, int treasureXp, Map<Enchantment, Integer> enchants) { |     public static McMMOPlayerFishingTreasureEvent callFishingTreasureEvent(Player player, ItemStack treasureDrop, int treasureXp, Map<Enchantment, Integer> enchants) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 GJ
					GJ