aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-10-12 22:31:49 +1100
committerGitHub <noreply@github.com>2023-10-12 13:31:49 +0200
commitdb0cd17c7019c072a5043ae8d0dca8ce6459fb32 (patch)
tree3e8a33b6d434d02d637e596eecd707d4e8c17495 /src/main/java/at/hannibal2/skyhanni/features
parentd4084e697899f6dc3ceb87b4d229e0fe3819440a (diff)
downloadskyhanni-db0cd17c7019c072a5043ae8d0dca8ce6459fb32.tar.gz
skyhanni-db0cd17c7019c072a5043ae8d0dca8ce6459fb32.tar.bz2
skyhanni-db0cd17c7019c072a5043ae8d0dca8ce6459fb32.zip
Fix + Backend: Made mouse buttons work as key binds (#560)
Fix + Backend: Made mouse buttons work as key binds #560
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt29
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt51
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt3
12 files changed, 63 insertions, 66 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt
index b12802f3b..4d08c371f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.chat
import at.hannibal2.skyhanni.data.ChatManager
+import at.hannibal2.skyhanni.utils.KeyboardUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.OSUtils
import io.github.moulberry.moulconfig.internal.GlScissorStack
@@ -58,7 +59,7 @@ class ChatFilterGui(private val history: List<ChatManager.MessageFilteringResult
)
}
if (mouseX in 0..w && mouseY in 0..(size * 10) && (isMouseButtonDown && !wasMouseButtonDown)) {
- if (LorenzUtils.isShiftKeyDown()) {
+ if (KeyboardUtils.isShiftKeyDown()) {
OSUtils.copyToClipboard(IChatComponent.Serializer.componentToJson(msg.message))
LorenzUtils.chat("Copied structured chat line to clipboard")
} else {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt
index f96c6d260..afbf7e16b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt
@@ -3,34 +3,33 @@ package at.hannibal2.skyhanni.features.event.diana
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.sorted
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent
-import org.lwjgl.input.Keyboard
+import kotlin.time.Duration.Companion.seconds
class BurrowWarpHelper {
- private var lastWarpTime = 0L
+ private var lastWarpTime = SimpleTimeMark.farPast()
private var lastWarp: WarpPoint? = null
@SubscribeEvent
- fun onKeyBindPressed(event: KeyInputEvent) {
+ fun onKeyClick(event: LorenzKeyPressEvent) {
if (!LorenzUtils.inSkyBlock) return
if (LorenzUtils.skyBlockIsland != IslandType.HUB) return
if (!config.burrowNearestWarp) return
- if (!Keyboard.getEventKeyState()) return
- val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey()
- if (config.keyBindWarp == key) {
- currentWarp?.let {
- if (System.currentTimeMillis() > lastWarpTime + 5_000) {
- lastWarpTime = System.currentTimeMillis()
- LorenzUtils.sendCommandToServer("warp " + currentWarp?.name)
- lastWarp = currentWarp
- }
+ if (event.keyCode != config.keyBindWarp) return
+
+ currentWarp?.let {
+ if (lastWarpTime.passedSince() < 5.seconds) {
+ lastWarpTime = SimpleTimeMark.now()
+ LorenzUtils.sendCommandToServer("warp " + currentWarp?.name)
+ lastWarp = currentWarp
}
}
}
@@ -40,8 +39,7 @@ class BurrowWarpHelper {
if (!LorenzUtils.inSkyBlock) return
if (event.message == "§cYou haven't unlocked this fast travel destination!") {
- val time = System.currentTimeMillis() - lastWarpTime
- if (time < 1_000) {
+ if (lastWarpTime.passedSince() < 1.seconds) {
lastWarp?.let {
it.unlocked = false
LorenzUtils.chat(
@@ -53,7 +51,6 @@ class BurrowWarpHelper {
}
}
}
-
}
companion object {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
index 8c139c923..caf2cb014 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.PacketEvent
@@ -25,8 +26,6 @@ import net.minecraft.network.play.server.S02PacketChat
import net.minecraftforge.event.entity.EntityJoinWorldEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import net.minecraftforge.fml.common.gameevent.InputEvent
-import org.lwjgl.input.Keyboard
import kotlin.time.Duration.Companion.seconds
object InquisitorWaypointShare {
@@ -164,13 +163,9 @@ object InquisitorWaypointShare {
}
@SubscribeEvent
- fun onKeyBindPressed(event: InputEvent.KeyInputEvent) {
+ fun onKeyClick(event: LorenzKeyPressEvent) {
if (!isEnabled()) return
- if (!Keyboard.getEventKeyState()) return
- val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey()
- if (config.keyBindShare == key) {
- sendInquisitor()
- }
+ if (event.keyCode == config.keyBindShare) sendInquisitor()
}
private fun sendDeath() {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt
index 00d3461e3..05083f442 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine
@@ -23,12 +23,12 @@ class GardenPlotBorders {
private fun LorenzVec.addXZ(x: Int, z: Int) = add(x, 0, z)
@SubscribeEvent
- fun onTick(event: LorenzTickEvent) {
+ fun onKeyClick(event: LorenzKeyPressEvent) {
if (!isEnabled()) return
-
- val keyPressed = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter() else Keyboard.getEventKey()
-
- if (keyPressed == Keyboard.KEY_G && Keyboard.isKeyDown(Keyboard.KEY_F3)) {
+ if (event.keyCode == Keyboard.KEY_G && Keyboard.isKeyDown(Keyboard.KEY_F3)) {
+ showBorders = !showBorders
+ }
+ if (event.keyCode == Keyboard.KEY_F3 && Keyboard.isKeyDown(Keyboard.KEY_G)) {
showBorders = !showBorders
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
index 5aa63b660..438fcf4a1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
@@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.features.garden.composter.ComposterAPI.getLevel
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.KeyboardUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector
@@ -421,7 +422,7 @@ class ComposterOverlay {
val name = itemName.substring(0, 2) + selected + rawItemName
list.add(Renderable.link("$name §8x${itemsNeeded.addSeparators()} §7(§6$format§7)") {
onClick(internalName)
- if (LorenzUtils.isControlKeyDown() && lastAttemptTime.passedSince() > 500.milliseconds) {
+ if (KeyboardUtils.isControlKeyDown() && lastAttemptTime.passedSince() > 500.milliseconds) {
lastAttemptTime = SimpleTimeMark.now()
retrieveMaterials(internalName, itemName, itemsNeeded.toInt())
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt
index 90274b4d6..e8add811e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt
@@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted
import at.hannibal2.skyhanni.utils.ItemUtils.isVanilla
+import at.hannibal2.skyhanni.utils.KeyboardUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.equalsOneOf
@@ -165,7 +166,7 @@ class HideNotClickableItems {
}
}
- private fun bypasssActive() = config.notClickableItemsBypass && LorenzUtils.isControlKeyDown()
+ private fun bypasssActive() = config.notClickableItemsBypass && KeyboardUtils.isControlKeyDown()
private fun isDisabled(): Boolean {
if (bypassUntil > System.currentTimeMillis()) return true
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt
index d2155a416..eee1b0613 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.KeyboardUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -38,7 +39,7 @@ class QuickCraftFeatures {
@SubscribeEvent
fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) {
if (!isEnabled()) return
- if (LorenzUtils.isControlKeyDown()) return
+ if (KeyboardUtils.isControlKeyDown()) return
if (event.gui !is GuiChest) return
val chest = event.gui.inventorySlots as ContainerChest
@@ -61,7 +62,7 @@ class QuickCraftFeatures {
val clickedItem = event.slot?.stack ?: return
- if (!LorenzUtils.isControlKeyDown() && needsQuickCraftConfirmation(clickedItem)) {
+ if (!KeyboardUtils.isControlKeyDown() && needsQuickCraftConfirmation(clickedItem)) {
event.isCanceled = true
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
index 98a16eb4c..9da2b804d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.utils.KeyboardUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.OSUtils
import kotlinx.coroutines.launch
@@ -15,7 +16,7 @@ class PasteIntoSigns {
if (!LorenzUtils.onHypixel) return
if (!SkyHanniMod.feature.misc.pasteIntoSigns) return
- val currentlyClicked = LorenzUtils.isPastingKeysDown()
+ val currentlyClicked = KeyboardUtils.isPastingKeysDown()
if (!lastClicked && currentlyClicked) {
SkyHanniMod.coroutineScope.launch {
OSUtils.readFromClipboard()?.let {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt
index 4870e2e6d..d0c81aa4a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.KeyboardUtils
import at.hannibal2.skyhanni.utils.LorenzRarity
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible
@@ -26,7 +27,7 @@ class PetExpTooltip {
fun onItemTooltipLow(event: ItemTooltipEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.petDisplay) return
- if (!LorenzUtils.isShiftKeyDown() && !config.showAlways) return
+ if (!KeyboardUtils.isShiftKeyDown() && !config.showAlways) return
val itemStack = event.itemStack ?: return
val petExperience = itemStack.getPetExp()?.round(1) ?: return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt
index a490bd944..225407778 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.FriendAPI
import at.hannibal2.skyhanni.data.GuildAPI
import at.hannibal2.skyhanni.data.PartyAPI
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
+import at.hannibal2.skyhanni.utils.KeyboardUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -113,7 +114,7 @@ object AdvancedPlayerList {
return newList
}
- fun ignoreCustomTabList() = SkyHanniMod.feature.dev.debugEnabled && LorenzUtils.isControlKeyDown()
+ fun ignoreCustomTabList() = SkyHanniMod.feature.dev.debugEnabled && KeyboardUtils.isControlKeyDown()
private val listOfSkyHanniDevsOrPeopeWhoKnowALotAboutModdingSeceneButAreBadInCoding = listOf(
"hannibal2",
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
index 73382b654..fa82ba18b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
@@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed
@@ -21,22 +21,20 @@ import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.getLorenzVec
import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.inventory.GuiChest
-import net.minecraft.client.gui.inventory.GuiEditSign
-import net.minecraft.client.gui.inventory.GuiInventory
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import org.lwjgl.input.Keyboard
import kotlin.concurrent.fixedRateTimer
+import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
@@ -54,10 +52,10 @@ object TrevorFeatures {
private var currentLabel = "§2Ready"
private var trapperID: Int = 56
private var backupTrapperID: Int = 17
- private var timeLastWarped: Long = 0
+ private var timeLastWarped = SimpleTimeMark.farPast()
private var lastChatPrompt = ""
- private var lastChatPromptTime = -1L
- private var teleportBlock = -1L
+ private var lastChatPromptTime = SimpleTimeMark.farPast()
+ private var teleportBlock = SimpleTimeMark.farPast()
var questActive = false
var inBetweenQuests = false
@@ -110,7 +108,7 @@ object TrevorFeatures {
trapperReady = false
TrevorTracker.startQuest(matcher)
updateTrapper()
- lastChatPromptTime = -1L
+ lastChatPromptTime = SimpleTimeMark.farPast()
}
matcher = talbotPatternAbove.matcher(event.message.removeColor())
@@ -126,7 +124,7 @@ object TrevorFeatures {
}
if (event.message.removeColor() == "[NPC] Trevor: You will have 10 minutes to find the mob from when you accept the task.") {
- teleportBlock = System.currentTimeMillis()
+ teleportBlock = SimpleTimeMark.now()
}
if (event.message.contains("§r§7Click an option: §r§a§l[YES]§r§7 - §r§c§l[NO]")) {
@@ -135,7 +133,7 @@ object TrevorFeatures {
for (sibling in siblings) {
if (sibling.chatStyle.chatClickEvent != null && sibling.chatStyle.chatClickEvent.value.contains("YES")) {
- lastChatPromptTime = System.currentTimeMillis()
+ lastChatPromptTime = SimpleTimeMark.now()
lastChatPrompt = sibling.chatStyle.chatClickEvent.value.drop(1)
}
}
@@ -244,28 +242,27 @@ object TrevorFeatures {
}
@SubscribeEvent
- fun onTick(event: LorenzTickEvent) {
+ fun onKeyClick(event: LorenzKeyPressEvent) {
if (!onFarmingIsland()) return
- if (!Keyboard.getEventKeyState()) return
-
- Minecraft.getMinecraft().currentScreen?.let {
- if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign) return
- }
+ if (Minecraft.getMinecraft().currentScreen != null) return
if (NEUItems.neuHasFocus()) return
- val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey()
- if (config.keyBindWarpTrapper == key) {
- if (lastChatPromptTime != -1L && config.acceptQuest && !questActive && System.currentTimeMillis() - 200 > lastChatPromptTime && System.currentTimeMillis() < lastChatPromptTime + 5000) {
- lastChatPromptTime = -1L
+
+ if (event.keyCode != config.keyBindWarpTrapper) return
+
+ if (config.acceptQuest) {
+ val timeSince = lastChatPromptTime.passedSince()
+ if (timeSince > 200.milliseconds && timeSince < 5.seconds) {
+ lastChatPromptTime = SimpleTimeMark.farPast()
LorenzUtils.sendCommandToServer(lastChatPrompt)
lastChatPrompt = ""
- timeLastWarped = System.currentTimeMillis()
+ timeLastWarped = SimpleTimeMark.now()
return
}
- if (System.currentTimeMillis() - timeLastWarped > 3000 && config.warpToTrapper) {
- if (System.currentTimeMillis() < teleportBlock + 5000) return
- LorenzUtils.sendCommandToServer("warp trapper")
- timeLastWarped = System.currentTimeMillis()
- }
+ }
+
+ if (config.warpToTrapper && timeLastWarped.passedSince() > 3.seconds && teleportBlock.passedSince() > 5.seconds) {
+ LorenzUtils.sendCommandToServer("warp trapper")
+ timeLastWarped = SimpleTimeMark.now()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
index ed85ba489..5c41ff0ca 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
@@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData
import at.hannibal2.skyhanni.test.PriceSource
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.KeyboardUtils
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
@@ -251,7 +252,7 @@ object SlayerItemProfitTracker {
) {
if (System.currentTimeMillis() > lastClickDelay + 150) {
- if (LorenzUtils.isControlKeyDown()) {
+ if (KeyboardUtils.isControlKeyDown()) {
itemLog.items.remove(internalName)
LorenzUtils.chat("§e[SkyHanni] Removed $cleanName §efrom slayer profit display.")
lastClickDelay = System.currentTimeMillis() + 500