Skip to content

Commit

Permalink
Add hotkey for picking up call
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidArthurCole committed Aug 19, 2024
1 parent e95337f commit dda5275
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
import io.github.notenoughupdates.moulconfig.observer.Property;
import org.lwjgl.input.Keyboard;

public class HoppityCallWarningConfig {

Expand All @@ -18,6 +20,16 @@ public class HoppityCallWarningConfig {
@FeatureToggle
public boolean enabled = false;

@Expose
@ConfigOption(
name = "Accept Call Hotkey",
desc = "Accept the call from hoppity by pressing this keybind."
)
@ConfigEditorKeybind(
defaultKey = Keyboard.KEY_NONE
)
public int acceptHotkey = Keyboard.KEY_NONE;

@Expose
@ConfigOption(name = "Warning Sound", desc = "The sound that plays when hoppity calls.\n" +
"§eYou can use custom sounds, put it in the §bskyhanni/sounds §efolder in your resource pack.\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package at.hannibal2.skyhanni.features.event.hoppity

import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiKeyPressEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColorInt
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SoundUtils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.Gui
import net.minecraft.client.renderer.GlStateManager
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.sin
import kotlin.time.Duration.Companion.seconds

@SkyHanniModule
object HoppityCallWarning {
Expand Down Expand Up @@ -43,6 +48,16 @@ object HoppityCallWarning {
private var nextWarningTime = 0L
private var finalWarningTime = 0L
private const val CALL_LENGTH_MS = 7000
private var lastAcceptSent = SimpleTimeMark.farPast()

@SubscribeEvent
fun onKeybind(event: GuiKeyPressEvent) {
if (!config.acceptHotkey.isKeyHeld()) return
if (lastAcceptSent.passedSince() < 3.seconds) return
lastAcceptSent = SimpleTimeMark.now()
// Call-back? Hoppity ID: eaf78cc9-260d-407f-b1df-efea83e5038a
HypixelCommands.cb("eaf78cc9-260d-407f-b1df-efea83e5038a")
}

@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ object HypixelCommands {
send("chatprompt $prompt")
}

fun cb(uuid: String) {
send("cb $uuid")
}

private fun send(command: String) {
@Suppress("DEPRECATION")
// TODO rename function
Expand Down

0 comments on commit dda5275

Please sign in to comment.