diff options
author | ILike2WatchMemes <ilike2watchmemes@gmail.com> | 2024-03-24 10:18:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-24 10:18:46 +0100 |
commit | bfeaeac6faa9e31319bb054ec800a13a23b11749 (patch) | |
tree | a090adc7b0efa6313c70ae2988eecc4ff9472cad /src/main/java | |
parent | 1ab016a7b0ef8965c9cd664a5618d1c3d78f3bcd (diff) | |
download | skyhanni-bfeaeac6faa9e31319bb054ec800a13a23b11749.tar.gz skyhanni-bfeaeac6faa9e31319bb054ec800a13a23b11749.tar.bz2 skyhanni-bfeaeac6faa9e31319bb054ec800a13a23b11749.zip |
Improvement: Plot Menu Highlighting and isBeingPasted for Plot (#1254)
Diffstat (limited to 'src/main/java')
3 files changed, 19 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/PlotMenuHighlightingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PlotMenuHighlightingConfig.java index 5918168e4..df758c04c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/PlotMenuHighlightingConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PlotMenuHighlightingConfig.java @@ -30,9 +30,10 @@ public class PlotMenuHighlightingConfig { public enum PlotStatusType { PESTS("§cPests", LorenzColor.RED), - SPRAYS("§eSprays", LorenzColor.YELLOW), + SPRAYS("§6Sprays", LorenzColor.GOLD), LOCKED("§7Locked", LorenzColor.DARK_GRAY), CURRENT("§aCurrent plot", LorenzColor.GREEN), + PASTING("§ePasting", LorenzColor.YELLOW) ; public final String name; diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt index 5ed6d2434..9402fa682 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt @@ -73,6 +73,9 @@ object GardenPlotAPI { var sprayHasNotified: Boolean, @Expose + var isBeingPasted: Boolean, + + @Expose var isPestCountInaccurate: Boolean, ) @@ -81,7 +84,7 @@ object GardenPlotAPI { val type: SprayType, ) - private fun Plot.getData() = GardenAPI.storage?.plotData?.getOrPut(id) { PlotData(id, "$id", 0, null, null, false, false) } + private fun Plot.getData() = GardenAPI.storage?.plotData?.getOrPut(id) { PlotData(id, "$id", 0, null, null, false, false, false) } var Plot.name: String get() = getData()?.name ?: "$id" @@ -107,6 +110,12 @@ object GardenPlotAPI { !it.sprayHasNotified && it.sprayExpiryTime?.isInPast() == true } == true + var Plot.isBeingPasted: Boolean + get() = this.getData()?.isBeingPasted ?: false + set(value) { + this.getData()?.isBeingPasted = value + } + var Plot.isPestCountInaccurate: Boolean get() = this.getData()?.isPestCountInaccurate ?: false set(value) { @@ -185,6 +194,7 @@ object GardenPlotAPI { for (plot in plots) { val itemStack = event.inventoryItems[plot.inventorySlot] ?: continue + plot.isBeingPasted = itemStack.getLore().any { it.contains("§7Pasting in progress:") } plot.unlocked = itemStack.getLore().all { !it.contains("§7Cost:") } plotNamePattern.matchMatcher(itemStack.name) { val plotName = group("name") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt index 165980a9f..9fe975499 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt @@ -2,10 +2,11 @@ package at.hannibal2.skyhanni.features.garden.inventory.plots import at.hannibal2.skyhanni.config.features.garden.PlotMenuHighlightingConfig.PlotStatusType import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenPlotAPI import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.currentSpray +import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isBeingPasted import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.pests import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.RenderUtils.highlight @@ -18,19 +19,21 @@ class GardenPlotMenuHighlighting { private var highlightedPlots = mutableMapOf<GardenPlotAPI.Plot, PlotStatusType>() @SubscribeEvent - fun onInventoryOpen(event: InventoryOpenEvent) { + fun onInventoryUpdate(event: InventoryUpdatedEvent) { if (!isEnabled()) return for (slot in InventoryUtils.getItemsInOpenChest()) { val list = mutableListOf<PlotStatusType>() val plot = GardenPlotAPI.plots.find { it.inventorySlot == slot.slotIndex } ?: continue - val (pestsEnabled, spraysEnabled, locksEnabled, currentEnabled) = PlotStatusType.entries.map { it in config.deskPlotStatusTypes } + val (pestsEnabled, spraysEnabled, locksEnabled, currentEnabled, pastesEnabled) = PlotStatusType.entries.map { it in config.deskPlotStatusTypes } if (plot.pests >= 1 && pestsEnabled) list.add(PlotStatusType.PESTS) if (plot.currentSpray != null && spraysEnabled) list.add(PlotStatusType.SPRAYS) if (!plot.unlocked && locksEnabled) list.add(PlotStatusType.LOCKED) if (plot == GardenPlotAPI.getCurrentPlot() && currentEnabled) list.add(PlotStatusType.CURRENT) + if (plot.isBeingPasted && pastesEnabled) list.add(PlotStatusType.PASTING) + println(plot.isBeingPasted) getLowestIndexItem(list)?.let { index -> val status = config.deskPlotStatusTypes[index] |