Skip to content

Commit 5350383

Browse files
authored
Improvement + Fix: Harvest Feast Visitor Drops + Charmed Visitor Rewards (hannibal002#5798)
1 parent 1a2835b commit 5350383

6 files changed

Lines changed: 42 additions & 4 deletions

File tree

src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import com.google.gson.JsonPrimitive
1313
object ConfigUpdaterMigrator {
1414

1515
val logger = SkyHanniLogger("ConfigMigration")
16-
const val CONFIG_VERSION = 133
16+
const val CONFIG_VERSION = 134
1717
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
1818
if (chain.isEmpty()) return this
1919
if (this !is JsonObject) return null

src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/DropsStatisticsConfig.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ class DropsStatisticsConfig {
4545
DropsStatisticsTextEntry.VOTER_BADGE_VIP,
4646
DropsStatisticsTextEntry.VOTER_BADGE_ELITE,
4747
DropsStatisticsTextEntry.VOTER_BADGE_SUPREME,
48+
DropsStatisticsTextEntry.VISITORS_GRATITUDE,
49+
DropsStatisticsTextEntry.FARMING_CONTEST_DISPLAY,
50+
DropsStatisticsTextEntry.ASTRONAUT_PERSONALITY,
51+
DropsStatisticsTextEntry.FAST_FOOD_BARN_SKIN,
52+
DropsStatisticsTextEntry.JELLY_GREENHOUSE_SKIN,
53+
4854
)
4955
)
5056

@@ -96,6 +102,11 @@ class DropsStatisticsConfig {
96102
CASHMERE_JACKET("§b6 §9Cashmere Jacket"),
97103
SATIN_TROUSERS("§b4 §9Satin Trousers"),
98104
OXFORD_SHOES("§b7 §9Oxford Shoes"),
105+
VISITORS_GRATITUDE("§b7 §fVisitors' Gratitude"),
106+
FARMING_CONTEST_DISPLAY("§b3 §aFarming Contest Display"),
107+
ASTRONAUT_PERSONALITY("§b1 §fAstronaut Minion Skin"),
108+
FAST_FOOD_BARN_SKIN("§b2 §6Fast Food Barn Skin"),
109+
JELLY_GREENHOUSE_SKIN("§b2 §6Jelly Garden Greenhouse Skin"),
99110
;
100111

101112
override fun toString() = displayName

src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTooltip.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ object GardenVisitorTooltip {
141141
readingShoppingList = false
142142
}
143143

144-
val (itemName, amount) = ItemUtils.readItemAmount(formattedLine) ?: continue
144+
val itemLine = if (readingShoppingList) formattedLine else formattedLine.removeCharmedSuffix()
145+
val (itemName, amount) = ItemUtils.readItemAmount(itemLine) ?: continue
145146
val internalName = NeuInternalName.fromItemNameOrNull(itemName.removeColor())
146147
?.replace("◆_", "") ?: continue
147148

@@ -224,7 +225,8 @@ object GardenVisitorTooltip {
224225
readingShoppingList = false
225226
}
226227

227-
val (itemName, amount) = ItemUtils.readItemAmount(formattedLine) ?: continue
228+
val itemLine = if (readingShoppingList) formattedLine else formattedLine.removeCharmedSuffix()
229+
val (itemName, amount) = ItemUtils.readItemAmount(itemLine) ?: continue
228230
val internalName = NeuInternalName.fromItemNameOrNull(itemName.removeColor())
229231
?.replace("◆_", "") ?: continue
230232

@@ -264,6 +266,8 @@ object GardenVisitorTooltip {
264266
visitor.blockReason = visitor.blockReason()
265267
}
266268

269+
private fun String.removeCharmedSuffix() = removeSuffix(" §d❤")
270+
267271
private fun getCropType(internalName: NeuInternalName) =
268272
CropType.getByNameOrNull(
269273
NeuItems.getPrimitiveMultiplier(internalName)

src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorApi.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,17 @@ object VisitorApi {
311311
event.transform(124, "garden.visitors.rewardWarning.drops") { element ->
312312
element.addElementsAfter(arrayOf(VisitorReward.DYE_WILD_STRAWBERRY))
313313
}
314+
event.transform(134, "garden.visitors.rewardWarning.drops") { element ->
315+
element.addElementsAfter(
316+
arrayOf(
317+
VisitorReward.VISITORS_GRATITUDE,
318+
VisitorReward.FARMING_CONTEST_DISPLAY,
319+
VisitorReward.ASTRONAUT_PERSONALITY,
320+
VisitorReward.FAST_FOOD_BARN_SKIN,
321+
VisitorReward.JELLY_GREENHOUSE_SKIN,
322+
)
323+
)
324+
}
314325

315326
event.move(18, "garden.visitors.needs", "garden.visitors.shoppingList")
316327

src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ enum class VisitorReward(rawInternalName: String, val displayName: String) {
3535
SATIN_TROUSERS("SATIN_TROUSERS", "§9Satin Trousers"),
3636
OXFORD_SHOES("OXFORD_SHOES", "§9Oxford Shoes"),
3737
CARNIVAL_TICKET("CARNIVAL_TICKET", "§aCarnival Ticket"),
38+
VISITORS_GRATITUDE("VISITORS_GRATITUDE", "§fVisitors' Gratitude"),
39+
FARMING_CONTEST_DISPLAY("FARMING_CONTEST_DISPLAY", "§aFarming Contest Display"),
40+
ASTRONAUT_PERSONALITY("ASTRONAUT_PERSONALITY", "§fAstronaut Minion Skin"),
41+
FAST_FOOD_BARN_SKIN("FAST_FOOD_BARN_SKIN", "§6Fast Food Barn Skin"),
42+
JELLY_GREENHOUSE_SKIN("JELLY_GREENHOUSE_SKIN", "§6Jelly Garden Greenhouse Skin"),
3843
;
3944

4045
private val internalName = rawInternalName.toInternalName()

src/test/java/at/hannibal2/skyhanni/test/garden/GardenVisitorTooltipTest.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import at.hannibal2.skyhanni.config.SkyHanniConfig
55
import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent
66
import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorTooltip
77
import at.hannibal2.skyhanni.features.garden.visitor.VisitorApi
8+
import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward
89
import at.hannibal2.skyhanni.utils.ItemUtils
910
import at.hannibal2.skyhanni.utils.NeuInternalName
1011
import at.hannibal2.skyhanni.utils.NeuInternalName.Companion.toInternalName
1112
import net.minecraft.world.item.Items
1213
import org.junit.jupiter.api.AfterEach
1314
import org.junit.jupiter.api.Assertions.assertDoesNotThrow
1415
import org.junit.jupiter.api.Assertions.assertNotNull
16+
import org.junit.jupiter.api.Assertions.assertTrue
1517
import org.junit.jupiter.api.BeforeEach
1618
import org.junit.jupiter.api.Test
1719

@@ -25,17 +27,20 @@ class GardenVisitorTooltipTest {
2527
SkyHanniMod.feature = SkyHanniConfig()
2628
SkyHanniMod.feature.garden.visitors.inventory.exactAmountAndTime = false
2729
SkyHanniMod.feature.garden.visitors.rewardWarning.notifyInChat = false
30+
SkyHanniMod.feature.garden.visitors.rewardWarning.drops.add(VisitorReward.VISITORS_GRATITUDE)
2831
itemNameCache()["§9Enchanted Sugar Cane"] = "ENCHANTED_SUGAR_CANE".toInternalName()
32+
itemNameCache()["Visitors' Gratitude"] = "VISITORS_GRATITUDE".toInternalName()
2933
}
3034

3135
@AfterEach
3236
fun tearDown() {
3337
itemNameCache().remove("§9Enchanted Sugar Cane")
38+
itemNameCache().remove("Visitors' Gratitude")
3439
SkyHanniMod.feature = oldConfig
3540
}
3641

3742
@Test
38-
fun `visitor tooltip parses copper line with heart suffix`() {
43+
fun `visitor tooltip parses copper line and rare reward with heart suffix`() {
3944
val offerItem = ItemUtils.createItemStack(Items.GREEN_TERRACOTTA, "§aAccept Offer", spacemanLore)
4045
val visitor = VisitorApi.Visitor(
4146
visitorName = "§cSpaceman",
@@ -48,6 +53,8 @@ class GardenVisitorTooltipTest {
4853
}
4954

5055
assertNotNull(visitor.pricePerCopper)
56+
assertTrue("VISITORS_GRATITUDE".toInternalName() in visitor.allRewards)
57+
assertTrue(VisitorReward.VISITORS_GRATITUDE in visitor.getRewardWarningAwards())
5158
}
5259

5360
companion object {

0 commit comments

Comments
 (0)