From 7df41f616b50515dd18551b472cc42e87d1b8543 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 6 Aug 2022 23:35:09 -0400 Subject: [PATCH] Invoke `AbilityManager#onSkillStart` and `AbilityManager#onSkillEnd` --- .../recv/HandlerClientAbilityInitFinishNotify.java | 11 +++++++---- .../packet/recv/HandlerEvtDoSkillSuccNotify.java | 12 +++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java index de87df3f2..1a0e3c138 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java @@ -11,20 +11,23 @@ import emu.grasscutter.utils.Utils; @Opcodes(PacketOpcodes.ClientAbilityInitFinishNotify) public class HandlerClientAbilityInitFinishNotify extends PacketHandler { - + @Override public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { ClientAbilityInitFinishNotify notif = ClientAbilityInitFinishNotify.parseFrom(payload); Player player = session.getPlayer(); + + // Call skill end in the player's ability manager. + player.getAbilityManager().onSkillEnd(player); + for (AbilityInvokeEntry entry : notif.getInvokesList()) { player.getAbilityManager().onAbilityInvoke(entry); player.getClientAbilityInitFinishHandler().addEntry(entry.getForwardType(), entry); } - + if (notif.getInvokesList().size() > 0) { session.getPlayer().getClientAbilityInitFinishHandler().update(session.getPlayer()); } } - -} +} \ No newline at end of file diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java index a714d936b..dc282d27e 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java @@ -12,10 +12,16 @@ public class HandlerEvtDoSkillSuccNotify extends PacketHandler { @Override public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { EvtDoSkillSuccNotify notify = EvtDoSkillSuccNotify.parseFrom(payload); + + var player = session.getPlayer(); int skillId = notify.getSkillId(); int casterId = notify.getCasterId(); - session.getPlayer().getStaminaManager().handleEvtDoSkillSuccNotify(session, skillId, casterId); - session.getPlayer().getEnergyManager().handleEvtDoSkillSuccNotify(session, skillId, casterId); + // Call skill perform in the player's ability manager. + player.getAbilityManager().onSkillStart(session.getPlayer(), skillId, casterId); + + // Handle skill notify in other managers. + player.getStaminaManager().handleEvtDoSkillSuccNotify(session, skillId, casterId); + player.getEnergyManager().handleEvtDoSkillSuccNotify(session, skillId, casterId); } -} +} \ No newline at end of file