aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorDavid Cole <40234707+DavidArthurCole@users.noreply.github.com>2024-07-26 05:10:25 -0400
committerGitHub <noreply@github.com>2024-07-26 11:10:25 +0200
commitf1ebd65ecfd633f89b7481918772593daddf66ba (patch)
treeedc058372e2f9ea3870696af45c14d5648d325a1 /src/main/java/at
parent77eb10263b65dbafac61a5e8ff0be552cd6c4617 (diff)
downloadskyhanni-f1ebd65ecfd633f89b7481918772593daddf66ba.tar.gz
skyhanni-f1ebd65ecfd633f89b7481918772593daddf66ba.tar.bz2
skyhanni-f1ebd65ecfd633f89b7481918772593daddf66ba.zip
Fix: Fine Flour in Sprayonator (#2251)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayType.kt1
2 files changed, 15 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt
index b01e6a08e..a87100202 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt
@@ -8,7 +8,6 @@ import at.hannibal2.skyhanni.features.garden.GardenPlotAPI
import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.renderPlot
import at.hannibal2.skyhanni.features.garden.pests.PestAPI.getPests
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
-import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -29,28 +28,29 @@ object SprayFeatures {
private val changeMaterialPattern by RepoPattern.pattern(
"garden.spray.material",
- "§a§lSPRAYONATOR! §r§7Your selected material is now §r§a(?<spray>.*)§r§7!"
+ "§a§lSPRAYONATOR! §r§7Your selected material is now §r§a(?<spray>.*)§r§7!",
)
+ private fun SprayType?.getSprayEffect(): String =
+ this?.getPests()?.takeIf { it.isNotEmpty() }?.let { pests ->
+ pests.joinToString("§7, §6") { it.displayName }
+ } ?: when (this) {
+ SprayType.FINE_FLOUR -> "§6+20☘ Farming Fortune"
+ else -> "§cUnknown Effect"
+ }
+
+
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
if (!isEnabled()) return
- val type = changeMaterialPattern.matchMatcher(event.message) {
+ display = changeMaterialPattern.matchMatcher(event.message) {
val sprayName = group("spray")
- SprayType.getByName(sprayName) ?: run {
- ErrorManager.logErrorStateWithData(
- "Error reading spray material", "SprayType is null",
- "sprayName" to sprayName,
- "event.message" to event.message,
- )
- return
- }
+ val type = SprayType.getByName(sprayName)
+ val sprayEffect = type.getSprayEffect()
+ "§a${type?.displayName ?: sprayName} §7(§6$sprayEffect§7)"
} ?: return
- val pests = type.getPests().joinToString("§7, §6") { it.displayName }
- display = "§a${type.displayName} §7(§6$pests§7)"
-
lastChangeTime = SimpleTimeMark.now()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayType.kt
index cb17de882..56ff022b8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayType.kt
@@ -6,6 +6,7 @@ enum class SprayType(val displayName: String) {
DUNG("Dung"),
HONEY_JAR("Honey Jar"),
TASTY_CHEESE("Tasty Cheese"),
+ FINE_FLOUR("Fine Flour"),
;
companion object {