From 031247ced40dd05358fc60a9bbf9ac5af9ae6a71 Mon Sep 17 00:00:00 2001
From: tylerswanson2 <31103658+tylerswanson2@users.noreply.github.com>
Date: Sat, 2 Dec 2023 21:08:29 -0500
Subject: [PATCH] Make DoubleJumpModule utilize ActionBarModule if present

---
 .../module/gameplay/DoubleJumpModule.kt       | 20 +++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/common/src/main/kotlin/com/bluedragonmc/server/module/gameplay/DoubleJumpModule.kt b/common/src/main/kotlin/com/bluedragonmc/server/module/gameplay/DoubleJumpModule.kt
index 5cabfecf..5621e181 100644
--- a/common/src/main/kotlin/com/bluedragonmc/server/module/gameplay/DoubleJumpModule.kt
+++ b/common/src/main/kotlin/com/bluedragonmc/server/module/gameplay/DoubleJumpModule.kt
@@ -84,14 +84,30 @@ class DoubleJumpModule(
         if (cooldownMillis > 0)
             eventNode.addListener(PlayerTickEvent::class.java) { event ->
                 val remainingMs = cooldownMillis - getTimeSinceLastJump(event.player)
-                if (remainingMs >= 0)
-                    event.player.sendActionBar(
+                if (remainingMs >= 0) {
+                    if (!parent.hasModule<ActionBarModule>()) {
+                        event.player.sendActionBar(
+                            abilityProgressBar(
+                                Component.translatable("global.ability.double_jump", ALT_COLOR_1, TextDecoration.BOLD),
+                                remainingMs.toInt(),
+                                cooldownMillis.toInt()
+                            )
+                        )
+                    }
+                }
+            }
+
+            eventNode.addListener(ActionBarModule.CollectActionBarEvent::class.java) { event ->
+                val remainingMs = cooldownMillis - getTimeSinceLastJump(event.player)
+                if (remainingMs >= 0) {
+                    event.addItem(
                         abilityProgressBar(
                             Component.translatable("global.ability.double_jump", ALT_COLOR_1, TextDecoration.BOLD),
                             remainingMs.toInt(),
                             cooldownMillis.toInt()
                         )
                     )
+                }
             }
     }