aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-12 14:56:58 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-06-12 14:56:58 +0200
commitfe9e6825401abe1309d915a3fa237322b33c6413 (patch)
tree0e4fc34749f28a6d2af7faf805cdb87c9f56c99c /src/main/java/at
parentb9bd547378f6e96fa41d7b48f1156f3ae3cbc7ab (diff)
downloadskyhanni-fe9e6825401abe1309d915a3fa237322b33c6413.tar.gz
skyhanni-fe9e6825401abe1309d915a3fa237322b33c6413.tar.bz2
skyhanni-fe9e6825401abe1309d915a3fa237322b33c6413.zip
Added composter empty timer for outside garden
Added composter soon empty warning for outside garden
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt45
3 files changed, 66 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 39b806520..27e9c0cf9 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -186,6 +186,12 @@ public class Storage {
@Expose
public Map<FarmingItems, ItemStack> farmingItems = new HashMap<>();
}
+
+ @Expose
+ public long composterEmptyTime = 0;
+
+ @Expose
+ public long lastComposterEmptyWarningTime = 0;
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
index b1a643f66..01d097338 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -1004,6 +1004,24 @@ public class Garden {
@Expose
@ConfigOption(
+ name = "Outside Garden",
+ desc = "Show Time till composter is empty outside garden"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 17)
+ public boolean composterDisplayOutsideGarden = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Composter warning",
+ desc = "Warn when the composter gets close to empty, even outside garden."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 17)
+ public boolean composterWarnAlmostClose = false;
+
+ @Expose
+ @ConfigOption(
name = "Upgrade Price",
desc = "Show the price for the composter upgrade in the lore."
)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt
index 8f6a34a18..e2f3b6710 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.TimeUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.*
import kotlin.time.Duration
import kotlin.time.DurationUnit
@@ -42,7 +43,7 @@ class ComposterDisplay {
@SubscribeEvent
fun onTabListUpdate(event: TabListUpdateEvent) {
- if (!isEnabled()) return
+ if (!(config.composterDisplayEnabled && GardenAPI.inGarden())) return
readData(event.tabList)
@@ -97,6 +98,7 @@ class ComposterDisplay {
private fun addComposterEmptyTime(emptyTime: Duration?): List<Any> {
return if (emptyTime != null) {
val millis = emptyTime.toDouble(DurationUnit.MILLISECONDS).toLong()
+ GardenAPI.config?.composterEmptyTime = System.currentTimeMillis() + millis
val format = TimeUtils.formatDuration(millis, maxUnits = 2)
listOf(NEUItems.getItemStack("BUCKET"), "§b$format")
} else {
@@ -160,10 +162,47 @@ class ComposterDisplay {
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
- if (isEnabled()) {
+ if (!LorenzUtils.inSkyBlock) return
+
+ if (GardenAPI.inGarden() && config.composterDisplayEnabled) {
config.composterDisplayPos.renderStringsAndItems(display, posLabel = "Composter Display")
}
+
+ checkWarningsAndOutsideGarden()
+ }
+
+ private fun checkWarningsAndOutsideGarden() {
+ val storage = GardenAPI.config ?: return
+
+ val format = if (storage.composterEmptyTime != 0L) {
+ val duration = storage.composterEmptyTime - System.currentTimeMillis()
+ if (duration > 0) {
+ if (duration < 1000 * 60 * 20) {
+ warn("Your composter in the garden is soon empty!")
+ }
+ TimeUtils.formatDuration(duration, maxUnits = 3)
+ } else {
+ warn("Your composter is empty!")
+ "§cComposter is empty!"
+ }
+ } else "?"
+
+ if (!GardenAPI.inGarden() && config.composterDisplayOutsideGarden) {
+ val list = Collections.singletonList(listOf(NEUItems.getItemStack("BUCKET"), "§b$format"))
+ config.composterDisplayPos.renderStringsAndItems(list, posLabel = "Composter Display")
+ }
}
- fun isEnabled() = config.composterDisplayEnabled && GardenAPI.inGarden()
+ private fun warn(warningMessage: String) {
+ if (!config.composterWarnAlmostClose) return
+ val storage = GardenAPI.config ?: return
+
+ if (LorenzUtils.inDungeons) return
+ if (LorenzUtils.inKuudraFight) return
+
+ if (System.currentTimeMillis() < storage.lastComposterEmptyWarningTime + 1000 * 60 * 2) return
+ storage.lastComposterEmptyWarningTime = System.currentTimeMillis()
+ LorenzUtils.chat("§e[SkyHanni] $warningMessage")
+ TitleUtils.sendTitle("§eComposter Warning!", 3_000)
+ }
} \ No newline at end of file