Skip to content

Commit

Permalink
Feature: "Not any pests" chat filter and "No pests!" title (hannibal0…
Browse files Browse the repository at this point in the history
…02#1957)

Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
3 people authored and MTOnline69 committed Sep 10, 2024
1 parent 2dac2c1 commit d835c49
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,15 +20,18 @@ 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
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
Expand All @@ -39,6 +43,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!",
)

@HandleEvent
fun onPestUpdate(event: PestUpdateEvent) {
Expand Down Expand Up @@ -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()
}
))
)
}
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d835c49

Please sign in to comment.