aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorErymanthus | RayDeeUx <51521765+RayDeeUx@users.noreply.github.com>2024-01-22 13:56:13 -0500
committerGitHub <noreply@github.com>2024-01-22 19:56:13 +0100
commit822913b506c63f8a322af76d3460a961e22b845c (patch)
tree3ff42b679f08cfc2786ad2c73b83570b6b3d8eac /src/main/java/at/hannibal2/skyhanni
parentb75ba0014350e4cf6880e481a24398da906b978d (diff)
downloadskyhanni-822913b506c63f8a322af76d3460a961e22b845c.tar.gz
skyhanni-822913b506c63f8a322af76d3460a961e22b845c.tar.bz2
skyhanni-822913b506c63f8a322af76d3460a961e22b845c.zip
Feature: Atmospheric Filter Display (#916)
Added Atmospheric Filter Display. #916
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/AtmosphericFilterDisplayConfig.java43
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt45
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/Season.kt29
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt5
6 files changed, 129 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 45c305c4b..7662c666e 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -146,6 +146,7 @@ import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishFillet
import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager
import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishMessages
import at.hannibal2.skyhanni.features.garden.AnitaMedalProfit
+import at.hannibal2.skyhanni.features.garden.AtmosphericFilterDisplay
import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.GardenCropMilestoneFix
@@ -586,6 +587,7 @@ class SkyHanniMod {
loadModule(GardenVisitorColorNames)
loadModule(TeleportPadCompactName())
loadModule(AnitaMedalProfit())
+ loadModule(AtmosphericFilterDisplay())
loadModule(AnitaExtraFarmingFortune())
loadModule(ComposterDisplay())
loadModule(GardenComposterInventoryFeatures())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/AtmosphericFilterDisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/AtmosphericFilterDisplayConfig.java
new file mode 100644
index 000000000..8235e8714
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/AtmosphericFilterDisplayConfig.java
@@ -0,0 +1,43 @@
+package at.hannibal2.skyhanni.config.features.garden;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+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.ConfigOption;
+
+public class AtmosphericFilterDisplayConfig {
+
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Toggles the Atmospheric Filter display to show the currently active buff.\n" +
+ "§eNote: For an optimal experience, please have the Atmospheric Filter accessory active.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Only Show Buff", desc = "Show only the currently active buff without the currently active season.")
+ @ConfigEditorBoolean
+ public boolean onlyBuff = false;
+
+ @Expose
+ @ConfigOption(name = "Abbreviate Season", desc = "Abbreviates the current season.")
+ @ConfigEditorBoolean
+ public boolean abbreviateSeason = false;
+
+ @Expose
+ @ConfigOption(name = "Abbreviate Perk", desc = "Abbreviates the currently active buff.")
+ @ConfigEditorBoolean
+ public boolean abbreviatePerk = false;
+
+ @Expose
+ @ConfigOption(name = "Outside Garden", desc = "Shows this HUD everywhere, including outside of the Garden.")
+ @ConfigEditorBoolean
+ public boolean everywhere = false;
+
+ @Expose
+ public Position position = new Position(10, 10, true, true);
+ @Expose
+ public Position positionOutside = new Position(20, 20, true, true);
+
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java
index b541cd0ee..cdea4e3ee 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java
@@ -120,6 +120,11 @@ public class GardenConfig {
public GardenCommandsConfig gardenCommands = new GardenCommandsConfig();
@Expose
+ @ConfigOption(name = "Atmospheric Filter Display", desc = "")
+ @Accordion
+ public AtmosphericFilterDisplayConfig atmosphericFilterDisplay = new AtmosphericFilterDisplayConfig();
+
+ @Expose
@ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt
new file mode 100644
index 000000000..73fd9804c
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt
@@ -0,0 +1,45 @@
+package at.hannibal2.skyhanni.features.garden
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.Season
+import io.github.moulberry.notenoughupdates.util.SkyBlockTime
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class AtmosphericFilterDisplay {
+
+ private val config get() = SkyHanniMod.feature.garden.atmosphericFilterDisplay
+
+ private var display = ""
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled()) return
+ if (!GardenAPI.inGarden() && !config.everywhere) return
+ if (!event.repeatSeconds(1)) return
+ display = drawDisplay(Season.getCurrentSeason() ?: return)
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
+ if (!isEnabled()) return
+ if (!GardenAPI.inGarden() && config.everywhere) {
+ config.positionOutside.renderString(display, posLabel = "Atmospheric Filter Perk Display")
+ } else if (GardenAPI.inGarden()) {
+ config.position.renderString(display, posLabel = "Atmospheric Filter Perk Display")
+ }
+ }
+
+ private fun drawDisplay(season: Season): String = buildString {
+ if (!config.onlyBuff) {
+ append(season.getSeason(config.abbreviateSeason))
+ append("§7: ")
+ }
+ append(season.getPerk(config.abbreviatePerk))
+ }
+
+ private fun isEnabled(): Boolean = LorenzUtils.inSkyBlock && config.enabled
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/Season.kt b/src/main/java/at/hannibal2/skyhanni/utils/Season.kt
new file mode 100644
index 000000000..ef139c15c
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/Season.kt
@@ -0,0 +1,29 @@
+package at.hannibal2.skyhanni.utils
+
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.UtilsPatterns.seasonPattern
+import io.github.moulberry.notenoughupdates.util.SkyBlockTime
+
+enum class Season(
+ val season: String,
+ val abbreviatedPerk: String,
+ val perk: String,
+) {
+
+ SPRING("§dSpring", "§6+25☘", "§7Gain §6+25☘ Farming Fortune§7."),
+ SUMMER("§6Summer", "§3+20☯", "§7Gain §3+20☯ Farming Wisdom§7."),
+ AUTUMN("§eAutumn", "§a15%+§4ൠ", "§4Pests §7spawn §a15% §7more often."),
+ WINTER("§9Winter", "§a5%+§cC", "§7Visitors give §a5% §7more §cCopper."),
+ ;
+
+ fun getPerk(abbreviate: Boolean): String = if (abbreviate) abbreviatedPerk else perk
+ fun getSeason(abbreviate: Boolean): String = if (abbreviate) season.take(4) else season
+
+ companion object {
+
+ fun getCurrentSeason(): Season? = getSeasonByName(SkyBlockTime.now().monthName)
+
+ private fun getSeasonByName(name: String): Season? = seasonPattern.matchMatcher(name) { entries.find { it.season.endsWith(group("season")) } }
+ }
+
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt
index 05bb4620b..abd5a940e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt
@@ -39,4 +39,9 @@ object UtilsPatterns {
"item.petlevel",
"(?:§f§f)?§7\\[Lvl (?<level>\\d+)] .*"
)
+
+ val seasonPattern by RepoPattern.pattern(
+ "skyblocktime.season",
+ "(?:Early |Late )?(?<season>Spring|Summer|Autumn|Winter)"
+ )
}