diff options
| author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-02-10 00:24:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-10 00:24:52 +0100 |
| commit | 4559e5ff05e19817a21ae49f1c0d8a97d273f6a1 (patch) | |
| tree | e72dac91d07fc84bea80548c89e13276caa68b81 /src/main/java/at/hannibal2/skyhanni/features/garden | |
| parent | d3a7cc4ab970b457b7950489da781539e45e0dce (diff) | |
| download | skyhanni-4559e5ff05e19817a21ae49f1c0d8a97d273f6a1.tar.gz skyhanni-4559e5ff05e19817a21ae49f1c0d8a97d273f6a1.tar.bz2 skyhanni-4559e5ff05e19817a21ae49f1c0d8a97d273f6a1.zip | |
Splitting many utils functions from LorenzUtils up into other classes: ChatUtils, CollectionUtils, ConditionalUtils. And code cleanup #978
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
73 files changed, 344 insertions, 226 deletions
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 e92fda526..19d658c2a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -6,13 +6,14 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems @@ -23,10 +24,12 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class AnitaMedalProfit { + private val config get() = GardenAPI.config.anitaShop private var display = emptyList<List<Any>>() companion object { + var inInventory = false } @@ -104,7 +107,7 @@ class AnitaMedalProfit { for (rawItemName in requiredItems) { val pair = ItemUtils.readItemAmount(rawItemName) if (pair == null) { - LorenzUtils.error("Could not read item '$rawItemName'") + ChatUtils.error("Could not read item '$rawItemName'") continue } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt index 73fd9804c..9fddb9fc6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.Season -import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class AtmosphericFilterDisplay { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt index 22d553ea4..c11c2640d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropAccessory.kt @@ -7,8 +7,9 @@ enum class CropAccessory( val internalName: NEUInternalName?, private val affectedCrops: Set<CropType>, private val fortune: Double, - val upgradeCost: Pair<String, Int>? + val upgradeCost: Pair<String, Int>?, ) { + NONE(null, emptySet(), 0.0, null), CROPIE( "CROPIE_TALISMAN".asInternalName(), @@ -29,6 +30,7 @@ enum class CropAccessory( } companion object { + fun getByName(internalName: NEUInternalName) = entries.firstOrNull { internalName == it.internalName } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt index 3a7226cc4..968fb1b29 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt @@ -15,34 +15,45 @@ enum class CropType( val simpleName: String, val replenish: Boolean = false, ) { - WHEAT("Wheat", "THEORETICAL_HOE_WHEAT", "CROPIE", 1.0, + + WHEAT( + "Wheat", "THEORETICAL_HOE_WHEAT", "CROPIE", 1.0, { ItemStack(Items.wheat) }, "wheat" ), - CARROT("Carrot", "THEORETICAL_HOE_CARROT", "CROPIE", 3.0, + CARROT( + "Carrot", "THEORETICAL_HOE_CARROT", "CROPIE", 3.0, { ItemStack(Items.carrot) }, "carrot", replenish = true ), - POTATO("Potato", "THEORETICAL_HOE_POTATO", "CROPIE", 3.0, + POTATO( + "Potato", "THEORETICAL_HOE_POTATO", "CROPIE", 3.0, { ItemStack(Items.potato) }, "potato", replenish = true ), - NETHER_WART("Nether Wart", "THEORETICAL_HOE_WARTS", "FERMENTO", 2.5, + NETHER_WART( + "Nether Wart", "THEORETICAL_HOE_WARTS", "FERMENTO", 2.5, { ItemStack(Items.nether_wart) }, "wart", replenish = true ), - PUMPKIN("Pumpkin", "PUMPKIN_DICER", "SQUASH", 1.0, + PUMPKIN( + "Pumpkin", "PUMPKIN_DICER", "SQUASH", 1.0, { ItemStack(Blocks.pumpkin) }, "pumpkin" ), - MELON("Melon", "MELON_DICER", "SQUASH", 5.0, + MELON( + "Melon", "MELON_DICER", "SQUASH", 5.0, { ItemStack(Items.melon) }, "melon" ), - COCOA_BEANS("Cocoa Beans", "COCO_CHOPPER", "SQUASH", 3.0, + COCOA_BEANS( + "Cocoa Beans", "COCO_CHOPPER", "SQUASH", 3.0, { ItemStack(Items.dye, 1, EnumDyeColor.BROWN.dyeDamage) }, "cocoa", replenish = true ), - SUGAR_CANE("Sugar Cane", "THEORETICAL_HOE_CANE", "FERMENTO", 2.0, + SUGAR_CANE( + "Sugar Cane", "THEORETICAL_HOE_CANE", "FERMENTO", 2.0, { ItemStack(Items.reeds) }, "cane" ), - CACTUS("Cactus", "CACTUS_KNIFE", "FERMENTO", 2.0, + CACTUS( + "Cactus", "CACTUS_KNIFE", "FERMENTO", 2.0, { ItemStack(Blocks.cactus) }, "cactus" ), - MUSHROOM("Mushroom", "FUNGI_CUTTER", "FERMENTO", 1.0, + MUSHROOM( + "Mushroom", "FUNGI_CUTTER", "FERMENTO", 1.0, { ItemStack(Blocks.red_mushroom_block) }, "mushroom" ), ; @@ -54,6 +65,7 @@ enum class CropType( override fun toString(): String = cropName companion object { + fun getByNameOrNull(itemName: String): CropType? { if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") return MUSHROOM if (itemName == "Seeds") return WHEAT diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index c7f05d807..5b066b142 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -14,11 +14,11 @@ import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.garden.CropType.Companion.getTurboCrop import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.pests.PestAPI +import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.LorenzUtils.nextAfter import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderString @@ -36,6 +36,7 @@ import kotlin.math.log10 import kotlin.time.Duration.Companion.seconds class FarmingFortuneDisplay { + private val tabFortuneUniversalPattern = " Farming Fortune: §r§6☘(?<fortune>\\d+)".toPattern() private val tabFortuneCropPattern = " (?<crop>Wheat|Carrot|Potato|Pumpkin|Sugar Cane|Melon|Cactus|Cocoa Beans|Mushroom|Nether Wart) Fortune: §r§6☘(?<fortune>\\d+)".toPattern() @@ -170,6 +171,7 @@ class FarmingFortuneDisplay { } companion object { + private val config get() = GardenAPI.config.farmingFortunes private val latestFF: MutableMap<CropType, Double>? get() = GardenAPI.storage?.latestTrueFarmingFortune diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingMilestoneCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingMilestoneCommand.kt index 7f7832ff1..61e3d1caa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingMilestoneCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingMilestoneCommand.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraft.command.CommandBase @@ -12,12 +12,12 @@ object FarmingMilestoneCommand { fun onCommand(crop: String?, current: String?, target: String?, needsTime: Boolean) { if (crop == null) { - LorenzUtils.userError("No crop type entered") + ChatUtils.userError("No crop type entered") return } val enteredCrop = CropType.entries.firstOrNull { it.simpleName == crop.lowercase() } ?: run { - LorenzUtils.userError("Invalid crop type entered") + ChatUtils.userError("Invalid crop type entered") return } @@ -30,7 +30,7 @@ object FarmingMilestoneCommand { val cropsForTier = GardenCropMilestones.getCropsForTier(currentCropMilestone, enteredCrop) val output = (cropsForTier - currentProgress).formatOutput(needsTime, enteredCrop) - LorenzUtils.chat("§7$output needed to reach the next milestone") + ChatUtils.chat("§7$output needed to reach the next milestone") return } @@ -38,11 +38,11 @@ object FarmingMilestoneCommand { val cropsForTier = GardenCropMilestones.getCropsForTier(currentMilestone, enteredCrop) val output = cropsForTier.formatOutput(needsTime, enteredCrop) - LorenzUtils.chat("§7$output needed for milestone §7$currentMilestone") + ChatUtils.chat("§7$output needed for milestone §7$currentMilestone") return } if (currentMilestone >= targetMilestone) { - LorenzUtils.userError("Entered milestone is greater than or the same as target milestone") + ChatUtils.userError("Entered milestone is greater than or the same as target milestone") |
