diff options
author | HiZe_ <superhize@hotmail.com> | 2023-12-08 18:17:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-08 18:17:37 +0100 |
commit | 75144d4b354cf0978173093ab12d691b572b12fb (patch) | |
tree | bab41fe78e887d9245557189eef71beefc8156c3 /src/main/java/at | |
parent | 96d5748a5300edc133bc52240001f753485bd8c3 (diff) | |
download | skyhanni-75144d4b354cf0978173093ab12d691b572b12fb.tar.gz skyhanni-75144d4b354cf0978173093ab12d691b572b12fb.tar.bz2 skyhanni-75144d4b354cf0978173093ab12d691b572b12fb.zip |
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
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/garden/pests/PestFinderConfig.java | 21 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/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 9f4b69d12..e06b69963 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 at.hannibal2.skyhanni.config.core.config.Position; 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,13 +31,21 @@ 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); @Expose 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 dfe34c56c..f2241090d 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<Renderable>() 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) } |