diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chat/FilterTypesConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chat/FilterTypesConfig.java index 0187af82eac6..8898ab68a957 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/chat/FilterTypesConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/chat/FilterTypesConfig.java @@ -105,6 +105,12 @@ 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; + @Expose @ConfigOption(name = "Block Alpha Achievements", desc = "Hide achievement messages while on the Alpha network.") @ConfigEditorBoolean 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 20f840084e54..587bfa73fd27 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 @@ -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) diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt index 303f8de371a7..ada41bab44a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.chat.PowderMiningChatFilter.genericMiningRewardMessage 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.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull @@ -496,6 +497,7 @@ object 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) -> "garden_pest" else -> null } 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 c508e08a50eb..d8754fd81e70 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 @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.api.event.HandleEvent 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 @@ -19,8 +20,10 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule 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.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation @@ -28,6 +31,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.SimpleTimeMark 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 @@ -39,6 +43,10 @@ object PestFinder { private val config get() = PestAPI.config.pestFinder private var display = emptyList() + val noPestsChatPattern by RepoPattern.pattern( + "chat.garden.no.pest", + "§cThere are not any Pests on your Garden right now! Keep farming!", + ) @HandleEvent fun onPestUpdate(event: PestUpdateEvent) { @@ -68,26 +76,28 @@ object PestFinder { "§7Pests Found: §e" + if (isInaccurate) "Unknown" else pests, "§7In plot §b$plotName", "", - "§eClick here to warp!" + "§eClick here to warp!", ), onClick = { plot.sendTeleportTo() - } + }, ) add(renderable) } if (PestAPI.getInfestedPlots().isEmpty() && PestAPI.scoreboardPests != 0) { add(Renderable.string("§e${PestAPI.scoreboardPests} §6Bugged pests!")) - add(Renderable.clickAndHover( - "§cTry opening your plots menu.", - listOf( - "Runs /desk." + add( + Renderable.clickAndHover( + "§cTry opening your plots menu.", + listOf( + "Runs /desk.", + ), + onClick = { + HypixelCommands.gardenDesk() + }, ), - onClick = { - HypixelCommands.gardenDesk() - } - )) + ) } } @@ -151,12 +161,20 @@ object PestFinder { pests ) + " §c$pestsName §7in §b$plotName" event.drawDynamicText( - location, text, 1.5 + location, text, 1.5, ) } private var lastKeyPress = SimpleTimeMark.farPast() + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!GardenAPI.inGarden()) return + if (!config.noPestTitle) return + + if (noPestsChatPattern.matches(event.message)) LorenzUtils.sendTitle("§eNo pests!", 2.seconds) + } + @SubscribeEvent fun onKeyClick(event: LorenzKeyPressEvent) { if (!GardenAPI.inGarden()) return