From 75144d4b354cf0978173093ab12d691b572b12fb Mon Sep 17 00:00:00 2001 From: HiZe_ Date: Fri, 8 Dec 2023 18:17:37 +0100 Subject: [PATCH] QOL: Show plot border for a given amount of seconds after holding vacuum (#771) Added an option to show plot borders for a given amount of seconds after holding a vacuum. #771 --- .../garden/pests/PestFinderConfig.java | 21 +++++++++++++------ .../features/garden/pests/PestFinder.kt | 14 +++++++++++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java index 9f4b69d122bd..e06b69963b95 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java @@ -5,6 +5,7 @@ import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; import io.github.moulberry.moulconfig.annotations.ConfigOption; import org.lwjgl.input.Keyboard; @@ -12,8 +13,8 @@ public class PestFinderConfig { @Expose @ConfigOption( - name = "Display", - desc = "Show a display with all know pest locations." + name = "Display", + desc = "Show a display with all know pest locations." ) @ConfigEditorBoolean @FeatureToggle @@ -21,8 +22,8 @@ public class PestFinderConfig { @Expose @ConfigOption( - name = "Show Plot in World", - desc = "Mark infected plot names and world border in the world." + name = "Show Plot in World", + desc = "Mark infected plot names and world border in the world." ) @ConfigEditorBoolean @FeatureToggle @@ -30,12 +31,20 @@ public class PestFinderConfig { @Expose @ConfigOption( - name = "Only With Vacuum", - desc = "Only show the pest display and waypoints while holding a vacuum in the hand." + name = "Only With Vacuum", + desc = "Only show the pest display and waypoints while holding a vacuum in the hand." ) @ConfigEditorBoolean public boolean onlyWithVacuum = true; + @Expose + @ConfigOption( + name = "Show For Seconds", + desc = "Show plots border for a given amount of seconds after holding a vacuum.\n§e0 = Always show when holding vacuum" + ) + @ConfigEditorSlider(minStep = 1, minValue = 0, maxValue = 10) + public int showBorderForSeconds = 1; + @Expose public Position position = new Position(-350, 200, 1.3f); diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt index dfe34c56c69d..f2241090d5ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.pests import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.IslandChangeEvent +import at.hannibal2.skyhanni.events.ItemInHandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent @@ -41,6 +42,7 @@ class PestFinder { private var display = emptyList() private var scoreboardPests = 0 + private var lastTimeVacuumHold = SimpleTimeMark.farPast() @SubscribeEvent fun onPestSpawn(event: PestSpawnEvent) { @@ -177,7 +179,7 @@ class PestFinder { fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return if (!config.showPlotInWorld) return - if (config.onlyWithVacuum && !PestAPI.hasVacuumInHand()) return + if (config.onlyWithVacuum && !PestAPI.hasVacuumInHand() && (lastTimeVacuumHold.passedSince() > config.showBorderForSeconds.seconds)) return val playerLocation = event.exactPlayerEyeLocation() for (plot in getPlotsWithPests()) { @@ -197,7 +199,7 @@ class PestFinder { } } - private var lastKeyPress = SimpleTimeMark.farPast() + private var lastKeyPress = SimpleTimeMark.farPast() @SubscribeEvent fun onKeyClick(event: LorenzKeyPressEvent) { @@ -222,5 +224,13 @@ class PestFinder { plot.sendTeleportTo() } + @SubscribeEvent + fun onItemInHandChange(event: ItemInHandChangeEvent) { + if (!isEnabled()) return + if (!config.showPlotInWorld) return + if (event.oldItem !in PestAPI.vacuumVariants) return + lastTimeVacuumHold = SimpleTimeMark.now() + } + fun isEnabled() = GardenAPI.inGarden() && (config.showDisplay || config.showPlotInWorld) }