diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt | 28 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayType.kt | 1 |
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 { |