aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/commands
diff options
context:
space:
mode:
authorClicks <58398364+CuzImClicks@users.noreply.github.com>2024-09-11 13:14:08 +0200
committerGitHub <noreply@github.com>2024-09-11 13:14:08 +0200
commit7aea6aa7b3774a3797f68a503eb42e99e88c2e56 (patch)
treed990a9f0bf7b4e7f11c231a01504b325db01f5ba /src/main/java/at/hannibal2/skyhanni/features/commands
parentc1f6c7242ae4f14556cfddbd2794694a5416b64f (diff)
downloadskyhanni-7aea6aa7b3774a3797f68a503eb42e99e88c2e56.tar.gz
skyhanni-7aea6aa7b3774a3797f68a503eb42e99e88c2e56.tar.bz2
skyhanni-7aea6aa7b3774a3797f68a503eb42e99e88c2e56.zip
Feature: Transfer Cooldown Prevention (#1751)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/commands')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/TransferCooldown.kt61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/TransferCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/TransferCooldown.kt
new file mode 100644
index 000000000..2a9c70cd9
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/TransferCooldown.kt
@@ -0,0 +1,61 @@
+package at.hannibal2.skyhanni.features.commands
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
+import at.hannibal2.skyhanni.events.MessageSendToServerEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.DelayedRun
+import at.hannibal2.skyhanni.utils.HypixelCommands
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
+
+@SkyHanniModule
+object TransferCooldown {
+
+ private val config get() = SkyHanniMod.feature.misc.commands
+ private var lastRunCompleted: SimpleTimeMark = SimpleTimeMark.farPast()
+ private var action: (() -> Unit)? = null
+
+ @SubscribeEvent
+ fun onWorldLoad(event: LorenzWorldChangeEvent) {
+ if (!config.transferCooldown || lastRunCompleted.isInFuture()) return
+ lastRunCompleted = DelayedRun.runDelayed(3.seconds) {
+ if (config.transferCooldownMessage && LorenzUtils.inSkyBlock) {
+ ChatUtils.chat("§aPlayer Transfer Cooldown has ended.")
+ }
+ action?.invoke()
+ action = null
+ }
+ }
+
+ @SubscribeEvent
+ fun onCommand(event: MessageSendToServerEvent) {
+ if (!LorenzUtils.inSkyBlock || !config.transferCooldown || lastRunCompleted.isInPast()) return
+ when (event.splitMessage[0]) {
+ "/is" -> {
+ event.cancel()
+ action = { HypixelCommands.island() }
+ }
+
+ "/warp" -> {
+ event.cancel()
+ action = {
+ HypixelCommands.warp(event.splitMessage.subList(1, event.splitMessage.size).joinToString(" "))
+ }
+ }
+
+ "/warpforge" -> {
+ event.cancel()
+ action = { HypixelCommands.warp("forge") }
+ }
+
+ "/hub" -> {
+ event.cancel()
+ action = { HypixelCommands.warp("hub") }
+ }
+ }
+ }
+}