summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/misc
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/misc
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/misc')
-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
4 files changed, 30 insertions, 30 deletions
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()
}
}