Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: "Not any pests" chat filter and "No pests!" title #1957

Merged
merged 8 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public class FilterTypesConfig {
@FeatureToggle
public boolean sacrifice = false;

@Expose
@ConfigOption(name = "Garden Pest", desc = "Hide the message of no pests on garden.")
@ConfigEditorBoolean
@FeatureToggle
public boolean gardenNoPest = false;

//TODO remove
@Expose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public String toString() {
@ConfigLink(owner = PestFinderConfig.class, field = "showDisplay")
public Position position = new Position(-350, 200, 1.3f);

@Expose
@ConfigOption(name = "No Pests Title", desc = "Show a Title in case of No pests. Useful if you are using the §eGarden Pest Chat Filter")
@ConfigEditorBoolean
public boolean noPestTitle = false;

@Expose
@ConfigOption(name = "Teleport Hotkey", desc = "Press this key to warp to the nearest plot with pests on it.")
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.pests.PestFinder
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils
Expand Down Expand Up @@ -489,6 +490,7 @@ class ChatFilter {
dungeonConfig.soloClass && DungeonAPI.inDungeon() && message.isPresent("solo_class") -> "solo_class"
dungeonConfig.soloStats && DungeonAPI.inDungeon() && message.isPresent("solo_stats") -> "solo_stats"
dungeonConfig.fairy && DungeonAPI.inDungeon() && message.isPresent("fairy") -> "fairy"
config.gardenNoPest && GardenAPI.inGarden() && PestFinder.noPestsChatPattern.matches(message) -> "gardenPest"
saga-00 marked this conversation as resolved.
Show resolved Hide resolved

else -> ""
}
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.config.features.garden.pests.PestFinderConfig.VisibilityType
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.garden.pests.PestUpdateEvent
Expand All @@ -18,14 +19,17 @@ import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
Expand All @@ -36,6 +40,10 @@ object PestFinder {
private val config get() = PestAPI.config.pestFinder

private var display = emptyList<Renderable>()
val noPestsChatPattern by RepoPattern.pattern(
"chat.garden.no.pest",
"§cThere are not any Pests on your Garden right now! Keep farming!"
)

@SubscribeEvent
fun onPestUpdate(event: PestUpdateEvent) {
Expand Down Expand Up @@ -154,6 +162,15 @@ object PestFinder {

private var lastKeyPress = SimpleTimeMark.farPast()

@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!config.noPestTitle) return

val containsCheck = GardenAPI.inGarden() && noPestsChatPattern.matches(event.message)

if (event.blockedReason == "gardenPest" || containsCheck) LorenzUtils.sendTitle("§eNo pests!", 2.seconds)
saga-00 marked this conversation as resolved.
Show resolved Hide resolved
}

@SubscribeEvent
fun onKeyClick(event: LorenzKeyPressEvent) {
if (!GardenAPI.inGarden()) return
Expand Down
Loading