Skip to content

Commit

Permalink
QOL: Show plot border for a given amount of seconds after holding vac…
Browse files Browse the repository at this point in the history
…uum (#771)

Added an option to show plot borders for a given amount of seconds after holding a vacuum. #771
  • Loading branch information
superhize authored Dec 8, 2023
1 parent 96d5748 commit 75144d4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,46 @@
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;

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
public boolean showDisplay = true;

@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
public boolean showPlotInWorld = true;

@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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand All @@ -197,7 +199,7 @@ class PestFinder {
}
}

private var lastKeyPress = SimpleTimeMark.farPast()
private var lastKeyPress = SimpleTimeMark.farPast()

@SubscribeEvent
fun onKeyClick(event: LorenzKeyPressEvent) {
Expand All @@ -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)
}

0 comments on commit 75144d4

Please sign in to comment.