aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt102
1 files changed, 55 insertions, 47 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index 2df429c7b..77ba00da7 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -81,23 +81,23 @@ object GardenVisitorFeatures {
private val patternGroup = RepoPattern.group("garden.visitor")
private val visitorArrivePattern by patternGroup.pattern(
"visitorarrive",
- ".* §r§ehas arrived on your §r§bGarden§r§e!"
+ ".* §r§ehas arrived on your §r§bGarden§r§e!",
)
private val copperPattern by patternGroup.pattern(
"copper",
- " §8\\+§c(?<amount>.*) Copper"
+ " §8\\+§c(?<amount>.*) Copper",
)
private val gardenExperiencePattern by patternGroup.pattern(
"gardenexperience",
- " §8\\+§2(?<amount>.*) §7Garden Experience"
+ " §8\\+§2(?<amount>.*) §7Garden Experience",
)
private val visitorChatMessagePattern by patternGroup.pattern(
"visitorchat",
- "§e\\[NPC] (?<color>§.)?(?<name>.*)§f: §r.*"
+ "§e\\[NPC] (?<color>§.)?(?<name>.*)§f: §r.*",
)
private val partialAcceptedPattern by patternGroup.pattern(
"partialaccepted",
- "§aYou gave some of the required items!"
+ "§aYou gave some of the required items!",
)
private val logger = LorenzLogger("garden/visitors")
@@ -130,7 +130,7 @@ object GardenVisitorFeatures {
"line" to line,
"offerItem" to offerItem,
"lore" to lore,
- "visitor" to visitor
+ "visitor" to visitor,
)
continue
}
@@ -194,13 +194,18 @@ object GardenVisitorFeatures {
list.add(" §7- ")
list.add(itemStack)
- list.add(Renderable.optionalLink("$name §ex${amount.addSeparators()}", {
- if (Minecraft.getMinecraft().currentScreen is GuiEditSign) {
- LorenzUtils.setTextIntoSign("$amount")
- } else {
- BazaarApi.searchForBazaarItem(name, amount)
- }
- }) { GardenAPI.inGarden() && !NEUItems.neuHasFocus() })
+ list.add(
+ Renderable.optionalLink(
+ "$name §ex${amount.addSeparators()}",
+ {
+ if (Minecraft.getMinecraft().currentScreen is GuiEditSign) {
+ LorenzUtils.setTextIntoSign("$amount")
+ } else {
+ BazaarApi.searchForBazaarItem(name, amount)
+ }
+ },
+ ) { GardenAPI.inGarden() && !NEUItems.neuHasFocus() },
+ )
if (config.shoppingList.showPrice) {
val price = internalName.getPrice() * amount
@@ -273,43 +278,46 @@ object GardenVisitorFeatures {
}
private fun MutableList<List<Any>>.drawVisitors(
- newVisitors: MutableList<String>,
- shoppingList: MutableMap<NEUInternalName, Int>,
+ newVisitors: List<String>,
+ shoppingList: Map<NEUInternalName, Int>,
) {
- if (newVisitors.isNotEmpty()) {
- if (shoppingList.isNotEmpty()) {
- addAsSingletonList("")
+ if (newVisitors.isEmpty()) return
+ if (shoppingList.isNotEmpty()) {
+ addAsSingletonList("")
+ }
+ val amount = newVisitors.size
+ val visitorLabel = if (amount == 1) "visitor" else "visitors"
+ addAsSingletonList("§e$amount §7new $visitorLabel:")
+ for (visitor in newVisitors) {
+ drawVisitor(visitor)
+ }
+ }
+
+ private fun MutableList<List<Any>>.drawVisitor(visitor: String) {
+ val displayName = GardenVisitorColorNames.getColoredName(visitor)
+
+ val list = mutableListOf<Any>()
+ list.add(" §7- $displayName")
+
+ if (config.shoppingList.itemPreview) {
+ val items = GardenVisitorColorNames.visitorItems[visitor.removeColor()]
+ if (items == null) {
+ val text = "Visitor '$visitor' has no items in repo!"
+ logger.log(text)
+ ChatUtils.debug(text)
+ list.add(" §7(§c?§7)")
+ return
}
- val amount = newVisitors.size
- val visitorLabel = if (amount == 1) "visitor" else "visitors"
- addAsSingletonList("§e$amount §7new $visitorLabel:")
- for (visitor in newVisitors) {
- val displayName = GardenVisitorColorNames.getColoredName(visitor)
-
- val list = mutableListOf<Any>()
- list.add(" §7- $displayName")
-
- if (config.shoppingList.itemPreview) {
- val items = GardenVisitorColorNames.visitorItems[visitor.removeColor()]
- if (items == null) {
- val text = "Visitor '$visitor' has no items in repo!"
- logger.log(text)
- ChatUtils.debug(text)
- list.add(" §7(§c?§7)")
- continue
- }
- if (items.isEmpty()) {
- list.add(" §7(§fAny§7)")
- } else {
- for (item in items) {
- list.add(NEUInternalName.fromItemName(item).getItemStack())
- }
- }
+ if (items.isEmpty()) {
+ list.add(" §7(§fAny§7)")
+ } else {
+ for (item in items) {
+ list.add(NEUInternalName.fromItemName(item).getItemStack())
}
-
- add(list)
}
}
+
+ add(list)
}
@SubscribeEvent
@@ -570,7 +578,7 @@ object GardenVisitorFeatures {
if (color != -1) {
RenderLivingEntityHelper.setEntityColor(
entity,
- color
+ color,
) { config.highlightStatus == HighlightMode.COLOR || config.highlightStatus == HighlightMode.BOTH }
}
// Haven't gotten either of the known effected visitors (Vex and Leo) so can't test for sure
@@ -689,7 +697,7 @@ object GardenVisitorFeatures {
event.move(
3,
"garden.visitorRewardWarning.preventRefusing",
- "garden.visitors.rewardWarning.preventRefusing"
+ "garden.visitors.rewardWarning.preventRefusing",
)
event.move(3, "garden.visitorRewardWarning.bypassKey", "garden.visitors.rewardWarning.bypassKey")
event.move(3, "garden.visitorRewardWarning.drops", "garden.visitors.rewardWarning.drops")