diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
5 files changed, 32 insertions, 36 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index 783f79f49..fa2f07038 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.bazaar import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.* -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -31,14 +31,10 @@ class BazaarApi { holder.getData(this) } else null - fun isBazaarItem(stack: ItemStack) = isBazaarItem(stack.getInternalName_old()) + fun isBazaarItem(stack: ItemStack) = stack.getInternalName().isBazaarItem() fun NEUInternalName.isBazaarItem() = NEUItems.manager.auctionManager.getBazaarInfo(asString()) != null - fun isBazaarItem(internalName: String): Boolean { - return NEUItems.manager.auctionManager.getBazaarInfo(internalName) != null - } - fun searchForBazaarItem(displayName: String, amount: Int = -1) { if (!LorenzUtils.inSkyBlock) return if (NEUItems.neuHasFocus()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt index e684cd04d..3fba348aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.utils.InventoryUtils object DianaAPI { - fun hasSpadeInHand() = InventoryUtils.itemInHandId == "ANCESTRAL_SPADE" + fun hasSpadeInHand() = InventoryUtils.itemInHandId.equals("ANCESTRAL_SPADE") fun isRitualActive() = MayorElection.isPerkActive("Diana", "Mythological Ritual") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt index da777f020..da7636cd6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed -import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.ItemUtils.getItemName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.NEUItems @@ -39,10 +39,10 @@ object GardenCropTimeCommand { val map = mutableMapOf<String, Long>() for (entry in CropMoneyDisplay.multipliers) { val internalName = entry.key - val itemName = NEUItems.getItemStack(internalName).name!! + val itemName = internalName.getItemName() if (itemName.removeColor().lowercase().contains(searchName)) { val (baseId, baseAmount) = NEUItems.getMultiplier(internalName) - val baseName = NEUItems.getItemStack(baseId).name!! + val baseName = baseId.getItemName() val crop = CropType.getByName(baseName.removeColor()) val fullAmount = baseAmount.toLong() * amount.toLong() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index 512610b2e..efb5b64e4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -6,6 +6,8 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.isBazaarItem import at.hannibal2.skyhanni.features.bazaar.BazaarData import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.CropType.Companion.getByNameOrNull @@ -13,15 +15,13 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.isSpeedDataEmpty -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.ItemUtils.getItemNameOrNull import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.moveEntryToTop import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc -import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName @@ -30,7 +30,7 @@ import kotlinx.coroutines.launch import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object CropMoneyDisplay { - var multipliers = mapOf<String, Int>() + var multipliers = mapOf<NEUInternalName, Int>() private var showCalculation = false @@ -44,7 +44,7 @@ object CropMoneyDisplay { private val config get() = SkyHanniMod.feature.garden private var loaded = false private var ready = false - private val cropNames = mutableMapOf<String, CropType>() // internalName -> cropName + private val cropNames = mutableMapOf<NEUInternalName, CropType>() private val toolHasBountiful get() = GardenAPI.config?.toolWithBountiful @SubscribeEvent @@ -130,9 +130,7 @@ object CropMoneyDisplay { extraMushroomCowPerkCoins = perSecond * 60 * 60 } - if (InventoryUtils.getItemInHand()?.getInternalName_old() - ?.contains("DICER") == true && config.moneyPerHourDicer - ) { + if (InventoryUtils.itemInHandId.contains("DICER") && config.moneyPerHourDicer) { var dicerDrops = 0.0 var bazaarData: BazaarData? = null if (it == CropType.MELON) { @@ -187,7 +185,7 @@ object CropMoneyDisplay { if (isSeeds(internalName)) { list.add(NEUItems.getItemStack("BOX_OF_SEEDS", true)) } else { - list.add(NEUItems.getItemStack(internalName)) + list.add(internalName.getItemStack()) } if (cropNames[internalName] == CropType.WHEAT && config.moneyPerHourMergeSeeds) { @@ -198,7 +196,7 @@ object CropMoneyDisplay { } if (!config.moneyPerHourCompact) { - val itemName = NEUItems.getItemStack(internalName).name?.removeColor() ?: continue + val itemName = internalName.getItemNameOrNull()?.removeColor() ?: continue val currentColor = if (isCurrent) "§e" else "§7" val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" list.add("$currentColor$contestFormat$itemName§7: ") @@ -259,8 +257,8 @@ object CropMoneyDisplay { LorenzUtils.formatInteger(moneyPerHour.toLong()) } - private fun calculateMoneyPerHour(debugList: MutableList<List<Any>>): Map<String, Array<Double>> { - val moneyPerHours = mutableMapOf<String, Array<Double>>() + private fun calculateMoneyPerHour(debugList: MutableList<List<Any>>): Map<NEUInternalName, Array<Double>> { + val moneyPerHours = mutableMapOf<NEUInternalName, Array<Double>>() var seedsPrice: BazaarData? = null var seedsPerHour = 0.0 @@ -312,7 +310,7 @@ object CropMoneyDisplay { debugList.addAsSingletonList(" cropsPerHour: ${cropsPerHour.addSeparators()}") } - val bazaarData = BazaarApi.getBazaarDataByInternalName(internalName) ?: continue + val bazaarData = internalName.getBazaarData() ?: continue var npcPrice = bazaarData.npcPrice * cropsPerHour var sellOffer = bazaarData.buyPrice * cropsPerHour @@ -351,7 +349,8 @@ object CropMoneyDisplay { return moneyPerHours } - private fun isSeeds(internalName: String) = (internalName == "ENCHANTED_SEEDS" || internalName == "SEEDS") + private fun isSeeds(internalName: NEUInternalName) = + internalName.equals("ENCHANTED_SEEDS") || internalName.equals("SEEDS") private fun formatNumbers(sellOffer: Double, instantSell: Double, npcPrice: Double): Array<Double> { return if (config.moneyPerHourUseCustomFormat) { @@ -381,16 +380,17 @@ object CropMoneyDisplay { loaded = true SkyHanniMod.coroutineScope.launch { - val map = mutableMapOf<String, Int>() - for ((internalName, _) in NEUItems.manager.itemInformation) { - if (!BazaarApi.isBazaarItem(internalName)) continue - if (internalName == "ENCHANTED_PAPER") continue - if (internalName == "ENCHANTED_BREAD") continue - if (internalName == "SIMPLE_CARROT_CANDY") continue - if (internalName == "BOX_OF_SEEDS") continue + val map = mutableMapOf<NEUInternalName, Int>() + for ((rawInternalName, _) in NEUItems.manager.itemInformation) { + if (rawInternalName == "ENCHANTED_PAPER") continue + if (rawInternalName == "ENCHANTED_BREAD") continue + if (rawInternalName == "SIMPLE_CARROT_CANDY") continue + if (rawInternalName == "BOX_OF_SEEDS") continue + val internalName = rawInternalName.asInternalName() + if (!internalName.isBazaarItem()) continue val (newId, amount) = NEUItems.getMultiplier(internalName) - val itemName = NEUItems.getItemStack(newId).name?.removeColor() ?: continue + val itemName = newId.getItemNameOrNull()?.removeColor() ?: continue val crop = getByNameOrNull(itemName) crop?.let { map[internalName] = amount diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt index 0ef0110ff..8e084f6c8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt @@ -15,7 +15,7 @@ class RiftHorsezookaHider { if (!SkyHanniMod.feature.rift.horsezookaHider) return if (event.entity is EntityHorse) { - if (InventoryUtils.itemInHandId == "HORSEZOOKA") { + if (InventoryUtils.itemInHandId.equals("HORSEZOOKA")) { event.isCanceled = true } } |