Skip to content

Commit 0a2d515

Browse files
committed
Hotfix 0.2.1
1 parent 7d9e5f4 commit 0a2d515

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

src/main/kotlin/io/github/frostzie/skyfall/features/garden/map/GardenMap.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ object GardenMap : IFeature {
5252
PestDetector.init()
5353
VisitorUtils.init()
5454

55-
ClientReceiveMessageEvents.ALLOW_GAME.register { message, _ ->
56-
SprayUtils.processChatMessage(message.string)
55+
ClientReceiveMessageEvents.ALLOW_GAME.register { message, overlay ->
56+
if (!overlay && IslandDetector.isOnIsland(IslandType.GARDEN)) {
57+
SprayUtils.processChatMessage(message.string)
58+
}
5759
true
5860
}
5961

src/main/kotlin/io/github/frostzie/skyfall/utils/garden/SprayUtils.kt

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,13 @@ package io.github.frostzie.skyfall.utils.garden
22

33
import io.github.frostzie.skyfall.data.GardenPlot
44
import io.github.frostzie.skyfall.data.GardenPlots
5-
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents
6-
import net.minecraft.text.Text
75
import net.minecraft.util.Formatting
86

97
object SprayUtils {
108

119
private val sprayedPlots: MutableMap<GardenPlot, Long> = mutableMapOf()
1210
private const val DEFAULT_SPRAY_DURATION_MIN = 30
1311

14-
init {
15-
ClientReceiveMessageEvents.ALLOW_GAME.register(::onReceiveMessage)
16-
}
17-
18-
/**
19-
* Callback for incoming chat messages.
20-
* It strips formatting from the message and processes only non-overlay chat.
21-
*/
22-
private fun onReceiveMessage(message: Text, overlay: Boolean): Boolean {
23-
if (overlay) return false
24-
val cleanMessage = Formatting.strip(message.string)
25-
println("SprayUtils: Received chat message: $cleanMessage")
26-
processChatMessage(cleanMessage.toString())
27-
return true
28-
}
29-
3012
/**
3113
* Returns a list of currently sprayed plots by removing any that have expired.
3214
*/
@@ -43,8 +25,9 @@ object SprayUtils {
4325
* Expected format: "SPRAYONATOR! You sprayed Plot - [number] ..."
4426
*/
4527
fun processChatMessage(message: String) {
28+
val cleanMessage = Formatting.strip(message) ?: return
4629
val chatRegex = """SPRAYONATOR!\s+You sprayed Plot - (\d+).*""".toRegex()
47-
val match = chatRegex.find(message)
30+
val match = chatRegex.find(cleanMessage)
4831
match?.groupValues?.get(1)?.toIntOrNull()?.let { plotNumber ->
4932
GardenPlots.allPlots.find { it.id == plotNumber }?.let { plot ->
5033
val expiration = System.currentTimeMillis() + DEFAULT_SPRAY_DURATION_MIN * 60 * 1000

0 commit comments

Comments
 (0)