aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt70
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt7
3 files changed, 71 insertions, 9 deletions
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 9402fa682..bab4cb3a8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt
@@ -40,6 +40,27 @@ object GardenPlotAPI {
"barnname",
"§.(?<name>The Barn)"
)
+ /**
+ * REGEX-TEST: §7Cleanup: §b0% Completed
+ */
+ private val uncleanedPlotPattern by patternGroup.pattern(
+ "uncleaned",
+ "§7Cleanup: .* (?:§.)*Completed"
+ )
+ /**
+ * REGEX-TEST: §aUnlocked Garden §r§aPlot §r§7- §r§b10§r§a!
+ */
+ private val unlockPlotChatPattern by patternGroup.pattern(
+ "chat.unlock",
+ "§aUnlocked Garden §r§aPlot §r§7- §r§b(?<plot>.*)§r§a!"
+ )
+ /**
+ * REGEX-TEST: §aPlot §r§7- §r§b10 §r§ais now clean!
+ */
+ private val cleanPlotChatPattern by patternGroup.pattern(
+ "chat.clean",
+ "§aPlot §r§7- §r§b(?<plot>.*) §r§ais now clean!"
+ )
private val plotSprayedPattern by patternGroup.pattern(
"spray.target",
"§a§lSPRAYONATOR! §r§7You sprayed §r§aPlot §r§7- §r§b(?<plot>.*) §r§7with §r§a(?<spray>.*)§r§7!"
@@ -51,7 +72,7 @@ object GardenPlotAPI {
return plots.firstOrNull { it.isPlayerInside() }
}
- class Plot(val id: Int, var unlocked: Boolean, var inventorySlot: Int, val box: AxisAlignedBB, val middle: LorenzVec)
+ class Plot(val id: Int, var inventorySlot: Int, val box: AxisAlignedBB, val middle: LorenzVec)
class PlotData(
@Expose
@@ -77,6 +98,12 @@ object GardenPlotAPI {
@Expose
var isPestCountInaccurate: Boolean,
+
+ @Expose
+ var locked: Boolean,
+
+ @Expose
+ var uncleared: Boolean,
)
data class SprayData(
@@ -84,7 +111,7 @@ object GardenPlotAPI {
val type: SprayType,
)
- private fun Plot.getData() = GardenAPI.storage?.plotData?.getOrPut(id) { PlotData(id, "$id", 0, null, null, false, false, false) }
+ private fun Plot.getData() = GardenAPI.storage?.plotData?.getOrPut(id) { PlotData(id, "$id", 0, null, null, false, false, false, true, false) }
var Plot.name: String
get() = getData()?.name ?: "$id"
@@ -122,6 +149,18 @@ object GardenPlotAPI {
this.getData()?.isPestCountInaccurate = value
}
+ var Plot.uncleared: Boolean
+ get() = this.getData()?.uncleared ?: false
+ set(value) {
+ this.getData()?.uncleared = value
+ }
+
+ var Plot.locked: Boolean
+ get() = this.getData()?.locked ?: false
+ set(value) {
+ this.getData()?.locked = value
+ }
+
fun Plot.markExpiredSprayAsNotified() {
getData()?.apply { sprayHasNotified = true }
}
@@ -164,7 +203,7 @@ object GardenPlotAPI {
val b = LorenzVec(maxX, 256.0, maxY)
val middle = a.interpolate(b, 0.5).copy(y = 10.0)
val box = a.axisAlignedTo(b).expand(0.0001, 0.0, 0.0001)
- list.add(Plot(id, false, slot, box, middle))
+ list.add(Plot(id, slot, box, middle))
slot++
}
slot += 4
@@ -185,6 +224,16 @@ object GardenPlotAPI {
plot?.setSpray(spray, 30.minutes)
}
+ cleanPlotChatPattern.matchMatcher(event.message) {
+ val plotId = group("plot").toInt()
+ val plot = getPlotByID(plotId)
+ plot?.uncleared = false
+ }
+ unlockPlotChatPattern.matchMatcher(event.message) {
+ val plotId = group("plot").toInt()
+ val plot = getPlotByID(plotId)
+ plot?.locked = false
+ }
}
@SubscribeEvent
@@ -194,8 +243,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:") }
+ val lore = itemStack.getLore()
plotNamePattern.matchMatcher(itemStack.name) {
val plotName = group("name")
plot.name = plotName
@@ -203,11 +251,23 @@ object GardenPlotAPI {
barnNamePattern.matchMatcher(itemStack.name) {
plot.name = group("name")
}
+ plot.locked = false
+ plot.isBeingPasted = false
+ for (line in lore) {
+ if (line.contains("§7Cost:")) plot.locked = true
+ if (line.contains("§7Pasting in progress:")) plot.isBeingPasted = true
+ plot.uncleared = false
+ uncleanedPlotPattern.matchMatcher(line) {
+ plot.uncleared = true
+ }
+ }
}
}
fun getPlotByName(plotName: String) = plots.firstOrNull { it.name == plotName }
+ fun getPlotByID(plotId: Int) = plots.firstOrNull { it.id == plotId }
+
fun LorenzRenderWorldEvent.renderPlot(
plot: Plot,
lineColor: Color,
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 f2160bc2a..bb658676a 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
@@ -7,6 +7,7 @@ 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.locked
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.pests
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
@@ -30,7 +31,7 @@ class GardenPlotMenuHighlighting {
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.locked && locksEnabled) list.add(PlotStatusType.LOCKED)
if (plot == GardenPlotAPI.getCurrentPlot() && currentEnabled) list.add(PlotStatusType.CURRENT)
if (plot.isBeingPasted && pastesEnabled) list.add(PlotStatusType.PASTING)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt
index 983e10384..842538774 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt
@@ -10,7 +10,9 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isBarn
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isPestCountInaccurate
+import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.locked
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.pests
+import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.uncleared
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
@@ -88,8 +90,7 @@ object PestAPI {
plot.pests = 1
plot.isPestCountInaccurate = false
}
- }
- if (inaccurateAmount == 1) { // if we can assume all the inaccurate pests are in the only inaccurate plot
+ } else if (inaccurateAmount == 1) { // if we can assume all the inaccurate pests are in the only inaccurate plot
val plot = getPlotsWithInaccuratePests().firstOrNull()
plot?.pests = scoreboardPests - accurateAmount
plot?.isPestCountInaccurate = false
@@ -128,7 +129,7 @@ object PestAPI {
if (event.inventoryName != "Configure Plots") return
for (plot in GardenPlotAPI.plots) {
- if (plot.isBarn()) continue
+ if (plot.isBarn() || plot.locked || plot.uncleared) continue
plot.pests = 0
plot.isPestCountInaccurate = false
val item = event.inventoryItems[plot.inventorySlot] ?: continue