aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/TransferCooldown.kt61
2 files changed, 73 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java
index 1747baee6..854ed39cc 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java
@@ -47,4 +47,16 @@ public class CommandsConfig {
@ConfigEditorBoolean
@FeatureToggle
public boolean viewRecipeLowerCase = true;
+
+ @Expose
+ @ConfigOption(name = "Fix Transfer Cooldown", desc = "Waits for the transfer cooldown to complete if you try to warp.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean transferCooldown = false;
+
+ @Expose
+ @ConfigOption(name = "Transfer Cooldown Ended Message", desc = "Sends a message in chat when the transfer cooldown ends.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean transferCooldownMessage = false;
}
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") }
+ }
+ }
+ }
+}