diff options
12 files changed, 95 insertions, 88 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/VisitorAcceptEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorAcceptEvent.kt index af6fa275a..4a494f353 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/VisitorAcceptEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorAcceptEvent.kt @@ -1,5 +1,6 @@ -package at.hannibal2.skyhanni.events +package at.hannibal2.skyhanni.events.garden.visitor +import at.hannibal2.skyhanni.events.LorenzEvent import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI class VisitorAcceptEvent(val visitor: VisitorAPI.Visitor) : LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRenderEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRenderEvent.kt index f050d53a5..7cbdc8224 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRenderEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorRenderEvent.kt @@ -4,6 +4,6 @@ import at.hannibal2.skyhanni.events.LorenzEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.utils.LorenzVec -import net.minecraftforge.client.event.RenderWorldLastEvent -class VisitorRenderEvent(val visitor: VisitorAPI.Visitor, val location: LorenzVec, val parent: LorenzRenderWorldEvent) : LorenzEvent()
\ No newline at end of file +class VisitorRenderEvent(val visitor: VisitorAPI.Visitor, val location: LorenzVec, val parent: LorenzRenderWorldEvent) : + LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt index daf1439f3..1bee8cff6 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/visitor/VisitorToolTipEvent.kt @@ -4,4 +4,5 @@ import at.hannibal2.skyhanni.events.LorenzEvent import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import net.minecraft.item.ItemStack -class VisitorToolTipEvent(val visitor: VisitorAPI.Visitor, val itemStack: ItemStack, val toolTip: MutableList<String>) : LorenzEvent()
\ No newline at end of file +class VisitorToolTipEvent(val visitor: VisitorAPI.Visitor, val itemStack: ItemStack, val toolTip: MutableList<String>) : + LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt index fd98cd437..d5c279fc9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -48,7 +47,7 @@ class AnitaMedalProfit { fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!config.medalProfitEnabled) return if (event.inventoryName != "Anita") return - if (VisitorAPI.inVisitorInventory) return + if (VisitorAPI.inInventory) return inInventory = true diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt index 618f48e59..c4b7fc0a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent -import at.hannibal2.skyhanni.events.VisitorAcceptEvent +import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList 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 378b72e35..954f1278c 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 @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.features.garden.visitor -import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -9,7 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent import at.hannibal2.skyhanni.events.TabListLineRenderEvent -import at.hannibal2.skyhanni.events.VisitorAcceptEvent +import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptedEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorArrivalEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent @@ -574,23 +573,23 @@ class GardenVisitorFeatures { event.move(3, "garden.visitorNeedsPos", "garden.visitors.needs.pos") event.move(3, "garden.visitorNeedsOnlyWhenClose", "garden.visitors.needs.onlyWhenClose") event.move(3, "garden.visitorNeedsInBazaarAlley", "garden.visitors.needs.inBazaarAlley") - event.move(3,"garden.visitorNeedsShowPrice", "garden.visitors.needs.showPrice") - event.move(3,"garden.visitorItemPreview", "garden.visitors.needs.itemPreview") + event.move(3, "garden.visitorNeedsShowPrice", "garden.visitors.needs.showPrice") + event.move(3, "garden.visitorItemPreview", "garden.visitors.needs.itemPreview") event.move(3, "garden.visitorShowPrice", "garden.visitors.inventory.showPrice") event.move(3, "garden.visitorExactAmountAndTime", "garden.visitors.inventory.exactAmountAndTime") event.move(3, "garden.visitorCopperPrice", "garden.visitors.inventory.copperPrice") event.move(3, "garden.visitorCopperTime", "garden.visitors.inventory.copperTime") event.move(3, "garden.visitorExperiencePrice", "garden.visitors.inventory.experiencePrice") - event.move(3,"garden.visitorRewardWarning.notifyInChat","garden.visitors.rewardWarning.notifyInChat") - event.move(3,"garden.visitorRewardWarning.showOverName","garden.visitors.rewardWarning.showOverName") - event.move(3,"garden.visitorRewardWarning.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") + event.move(3, "garden.visitorRewardWarning.notifyInChat", "garden.visitors.rewardWarning.notifyInChat") + event.move(3, "garden.visitorRewardWarning.showOverName", "garden.visitors.rewardWarning.showOverName") + event.move(3, "garden.visitorRewardWarning.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") event.move(3, "garden.visitorNotificationChat", "garden.visitors.notificationChat") event.move(3, "garden.visitorNotificationTitle", "garden.visitors.notificationTitle") event.move(3, "garden.visitorHighlightStatus", "garden.visitors.highlightStatus") event.move(3, "garden.visitorColoredName", "garden.visitors.coloredName") - event.move(3,"garden.visitorHypixelArrivedMessage","garden.visitors.hypixelArrivedMessage") + event.move(3, "garden.visitorHypixelArrivedMessage", "garden.visitors.hypixelArrivedMessage") event.move(3, "garden.visitorHideChat", "garden.visitors.hideChat") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt index 4f9bbb23d..a1a7b5110 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt @@ -18,7 +18,7 @@ import net.minecraft.item.ItemStack object VisitorAPI { private var visitors = mapOf<String, Visitor>() - var inVisitorInventory = false + var inInventory = false val config get() = SkyHanniMod.feature.garden.visitors private val logger = LorenzLogger("garden/visitors/api") @@ -41,9 +41,11 @@ object VisitorAPI { VisitorStatus.ACCEPTED -> { VisitorAcceptedEvent(visitor).postAndCatch() } + VisitorStatus.REFUSED -> { VisitorRefusedEvent(visitor).postAndCatch() } + else -> {} } } @@ -62,8 +64,8 @@ object VisitorAPI { println("visitors: $visitors") println("name: $name") ErrorManager.logErrorState( - "Error finding the visitor `$name§c`. Try to reopen the inventory", - "visitor is null! name='$name', visitors=`$visitors`" + "Error finding the visitor `$name§c`. Try to reopen the inventory", + "visitor is null! name='$name', visitors=`$visitors`" ) return null } @@ -98,17 +100,17 @@ object VisitorAPI { } class VisitorOffer( - val offerItem: ItemStack + val offerItem: ItemStack ) class Visitor( - val visitorName: String, - var entityId: Int = -1, - var nameTagEntityId: Int = -1, - var status: VisitorStatus, - var inSacks: Boolean = false, - val items: MutableMap<NEUInternalName, Int> = mutableMapOf(), - var offer: VisitorOffer? = null, + val visitorName: String, + var entityId: Int = -1, + var nameTagEntityId: Int = -1, + var status: VisitorStatus, + var inSacks: Boolean = false, + val items: MutableMap<NEUInternalName, Int> = mutableMapOf(), + var offer: VisitorOffer? = null, ) { var lore: List<String> = emptyList() var allRewards = listOf<NEUInternalName>() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt index c03d666f9..98a48a76a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt @@ -117,7 +117,7 @@ class VisitorListener { val offerItem = event.inventoryItems[VISITOR_ACCEPT_ITEM_SLOT] ?: return if (offerItem.name != "§aAccept Offer") return - VisitorAPI.inVisitorInventory = true + VisitorAPI.inInventory = true val visitorOffer = VisitorAPI.VisitorOffer(offerItem) @@ -135,12 +135,12 @@ class VisitorListener { @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { - VisitorAPI.inVisitorInventory = false + VisitorAPI.inInventory = false } @SubscribeEvent(priority = EventPriority.HIGH) fun onStackClick(event: SlotClickEvent) { - if (!VisitorAPI.inVisitorInventory) return + if (!VisitorAPI.inInventory) return if (event.clickType != 0) return val visitor = VisitorAPI.getVisitor(lastClickedNpc) ?: return @@ -179,7 +179,7 @@ class VisitorListener { @SubscribeEvent(priority = EventPriority.HIGH) fun onTooltip(event: ItemTooltipEvent) { if (!GardenAPI.onBarnPlot) return - if (!VisitorAPI.inVisitorInventory) return + if (!VisitorAPI.inInventory) return val visitor = VisitorAPI.getVisitor(lastClickedNpc) ?: return VisitorToolTipEvent(visitor, event.itemStack, event.toolTip).postAndCatch() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index 7e015b09c..97278e9f9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -8,7 +8,6 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.features.rift.RiftAPI.motesNpcPrice @@ -386,7 +385,7 @@ class HideNotClickableItems { private fun hideNpcSell(chestName: String, stack: ItemStack): Boolean { if (!tradeNpcFilter.match(chestName)) return false - if (VisitorAPI.inVisitorInventory) return false + if (VisitorAPI.inInventory) return false reverseColor = true var name = stack.cleanName() diff --git a/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorAPITest.kt b/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorAPITest.kt index 74baf866a..c8e7923f7 100644 --- a/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorAPITest.kt +++ b/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorAPITest.kt @@ -21,31 +21,37 @@ class VisitorAPITest { // To short assert( - VisitorAPI.isVisitorInfo(mutableListOf( - "§a§lVisitor Info", - "§7§oClick to view info about this visitor." - )) == false + !VisitorAPI.isVisitorInfo( + mutableListOf( + "§a§lVisitor Info", + "§7§oClick to view info about this visitor." + ) + ) ) // To long assert( - VisitorAPI.isVisitorInfo(mutableListOf( - "§a§lVisitor Info", - "§7§oClick to view info about this visitor.", - "§7§oClick to view info about this visitor.", - "§7§oClick to view info about this visitor.", - "§7§oClick to view info about this visitor.", - )) == false + !VisitorAPI.isVisitorInfo( + mutableListOf( + "§a§lVisitor Info", + "§7§oClick to view info about this visitor.", + "§7§oClick to view info about this visitor.", + "§7§oClick to view info about this visitor.", + "§7§oClick to view info about this visitor.", + ) + ) ) // Third line is §7Offers Accepted: §a assert( - VisitorAPI.isVisitorInfo(mutableListOf( - "§a§lVisitor Info", - "§7§oClick to view info about this visitor.", - "§7§oClick to view info about this visitor.", - "§7Offers Accepted: §a", - )) == true + VisitorAPI.isVisitorInfo( + mutableListOf( + "§a§lVisitor Info", + "§7§oClick to view info about this visitor.", + "§7§oClick to view info about this visitor.", + "§7Offers Accepted: §a", + ) + ) ) } }
\ No newline at end of file diff --git a/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorListenerTest.kt b/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorListenerTest.kt index 13e96a019..c95e4ec03 100644 --- a/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorListenerTest.kt +++ b/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorListenerTest.kt @@ -12,9 +12,9 @@ import io.mockk.verify import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test - class VisitorListenerTest { private lateinit var listener: VisitorListener + @BeforeEach fun setUp() { mockkObject(GardenAPI) @@ -32,14 +32,16 @@ class VisitorListenerTest { @Test fun `onTablistUpdate it should add new visitors to the list`() { listener.onTabListUpdate( - TabListUpdateEvent(mutableListOf( - "§b§lVisitors:", - "§cSpaceman", - "§cGrandma Wolf", - "ThePlayerName", - "Jacob", - "", - )) + TabListUpdateEvent( + mutableListOf( + "§b§lVisitors:", + "§cSpaceman", + "§cGrandma Wolf", + "ThePlayerName", + "Jacob", + "", + ) + ) ) verify { VisitorAPI.addVisitor("§fJacob") } @@ -50,14 +52,13 @@ class VisitorListenerTest { @Test fun `onTablistUpdate it should remove visitors from the list`() { every { VisitorAPI.getVisitors() } returns listOf( - mockk { every { visitorName } returns "§fJacob" }, + mockk { every { visitorName } returns "§fJacob" }, ) listener.onTabListUpdate( - TabListUpdateEvent(mutableListOf( - "§b§lVisitors:", - "", - )) + TabListUpdateEvent( + mutableListOf("§b§lVisitors:", "") + ) ) verify { VisitorAPI.removeVisitor("§fJacob") } @@ -66,16 +67,15 @@ class VisitorListenerTest { @Test fun `onTablistUpdate it should not remove visitors if the timeout is not hit`() { every { VisitorAPI.getVisitors() } returns listOf( - mockk { every { visitorName } returns "§fJacob" }, + mockk { every { visitorName } returns "§fJacob" }, ) every { LorenzUtils.lastWorldSwitch } returns System.currentTimeMillis() listener.onTabListUpdate( - TabListUpdateEvent(mutableListOf( - "§b§lVisitors:", - "", - )) + TabListUpdateEvent( + mutableListOf("§b§lVisitors:", "") + ) ) verify(exactly = 0) { VisitorAPI.removeVisitor("§fJacob") } diff --git a/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorToolTipParserTest.kt b/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorToolTipParserTest.kt index 9418b3db8..0f2ad1fee 100644 --- a/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorToolTipParserTest.kt +++ b/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorToolTipParserTest.kt @@ -6,18 +6,18 @@ import org.junit.jupiter.api.Test class VisitorToolTipParserTest { private val lore = mutableListOf( - "§7Items Required:", - " §aEnchanted Hay Bale §8x28", - "", - "§7Rewards:", - " §8+§37.2k §7Farming XP", - " §8+§215 §7Garden Experience", - " §8+§c23 Copper", - " §8+§b10 Bits", - " §aJacob's Ticket", - " §9Flowering Bouquet", - "", - "§eClick to give!" + "§7Items Required:", + " §aEnchanted Hay Bale §8x28", + "", + "§7Rewards:", + " §8+§37.2k §7Farming XP", + " §8+§215 §7Garden Experience", + " §8+§c23 Copper", + " §8+§b10 Bits", + " §aJacob's Ticket", + " §9Flowering Bouquet", + "", + "§eClick to give!" ) @Test @@ -39,12 +39,12 @@ class VisitorToolTipParserTest { } val assertions = mutableMapOf( - "§7Farming XP" to 7200, - "§7Garden Experience" to 15, - "Copper" to 23, - "Bits" to 10, - "§aJacob's Ticket" to 1, - "§9Flowering Bouquet" to 1 + "§7Farming XP" to 7200, + "§7Garden Experience" to 15, + "Copper" to 23, + "Bits" to 10, + "§aJacob's Ticket" to 1, + "§9Flowering Bouquet" to 1 ) for ((itemName, amount) in assertions) { |