aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/garden
diff options
context:
space:
mode:
authorefefury <69400149+efefury@users.noreply.github.com>2023-04-12 21:12:22 +0000
committerGitHub <noreply@github.com>2023-04-12 23:12:22 +0200
commit8f8df60eb5f8bc69eb76b385f4298d29ca8ca649 (patch)
treebe9dd5308cc04c96ceff75f5ebaf12eb9e09cc31 /src/main/java/at/hannibal2/skyhanni/features/garden
parent5021f7d8d9403a84c9df0ca6e1ac279c30c3c879 (diff)
downloadskyhanni-8f8df60eb5f8bc69eb76b385f4298d29ca8ca649.tar.gz
skyhanni-8f8df60eb5f8bc69eb76b385f4298d29ca8ca649.tar.bz2
skyhanni-8f8df60eb5f8bc69eb76b385f4298d29ca8ca649.zip
added notification when organic matter/fuel is low in composter (#40)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/ComposterDisplay.kt38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ComposterDisplay.kt
index 7f37c6867..23316166f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/ComposterDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ComposterDisplay.kt
@@ -1,24 +1,28 @@
package at.hannibal2.skyhanni.features.garden
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.SendTitleHelper
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.NEUItems
+import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Pattern
class ComposterDisplay {
private val config get() = SkyHanniMod.feature.garden
+ private val hidden get() = SkyHanniMod.feature.hidden
private var display = listOf<List<Any>>()
enum class DataType(val pattern: String, val icon: String) {
ORGANIC_MATTER(" Organic Matter: §r(.*)", "WHEAT"),
FUEL(" Fuel: §r(.*)", "OIL_BARREL"),
TIME_LEFT(" Time Left: §r(.*)", "WATCH"),
- STORED_COMPOST(" Stored Compost: §r(.*)", "COMPOST"),
- ;
+ STORED_COMPOST(" Stored Compost: §r(.*)", "COMPOST");
val displayItem by lazy {
NEUItems.getItemStack(icon)
@@ -71,6 +75,36 @@ class ComposterDisplay {
newList.add(DataType.STORED_COMPOST.addToList(data))
display = newList
+
+ notify(data)
+ }
+
+ private fun notify(data: MutableMap<DataType, String>) {
+ if (!config.composterNotifyLowEnabled) return
+
+ data[DataType.ORGANIC_MATTER]?.removeColor()?.formatNumber()?.let {
+ if (it <= config.composterNotifyLowOrganicMatter) {
+ if (System.currentTimeMillis() >= hidden.informedAboutLowMatter) {
+ if (config.composterNotifyLowTitle) {
+ SendTitleHelper.sendTitle("§cYour Organic Matter is low", 4_000)
+ }
+ LorenzUtils.chat("§e[SkyHanni] §cYour Organic Matter is low!")
+ hidden.informedAboutLowMatter = System.currentTimeMillis() + 30_000
+ }
+ }
+ }
+
+ data[DataType.FUEL]?.removeColor()?.formatNumber()?.let {
+ if (it <= config.composterNotifyLowFuel &&
+ System.currentTimeMillis() >= hidden.informedAboutLowFuel
+ ) {
+ if (config.composterNotifyLowTitle) {
+ SendTitleHelper.sendTitle("§cYour Fuel is low", 4_000)
+ }
+ LorenzUtils.chat("§e[SkyHanni] §cYour Fuel is low!")
+ hidden.informedAboutLowFuel = System.currentTimeMillis() + 30_000
+ }
+ }
}
@SubscribeEvent