aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-09 14:55:06 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-08-09 14:55:06 +0200
commit0efd1b797bbca2eb144b3ec795217ee2e9077c23 (patch)
tree00ac1262c6b7e3e676794c75ce3dfb86873f4f7b /src/main/java/at/hannibal2/skyhanni
parent5607930d95e526c529dac318d8e958b7b4de052b (diff)
downloadskyhanni-0efd1b797bbca2eb144b3ec795217ee2e9077c23.tar.gz
skyhanni-0efd1b797bbca2eb144b3ec795217ee2e9077c23.tar.bz2
skyhanni-0efd1b797bbca2eb144b3ec795217ee2e9077c23.zip
Using NEUInternalName in even more classes
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/ItemInHandChangeEvent.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt50
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt5
11 files changed, 47 insertions, 47 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt
index d7371cfa6..bc626a156 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt
@@ -2,9 +2,10 @@ package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.*
import at.hannibal2.skyhanni.utils.InventoryUtils
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzVec
+import at.hannibal2.skyhanni.utils.NEUInternalName
import net.minecraft.client.Minecraft
import net.minecraft.network.play.server.S29PacketSoundEffect
import net.minecraft.network.play.server.S2APacketParticles
@@ -71,12 +72,12 @@ class MinecraftData {
fun onTick(event: LorenzTickEvent) {
if (!LorenzUtils.inSkyBlock) return
val hand = InventoryUtils.getItemInHand()
- val newItem = hand?.getInternalName_old() ?: ""
+ val newItem = hand?.getInternalName() ?: NEUInternalName.NONE
if (newItem != InventoryUtils.itemInHandId) {
ItemInHandChangeEvent(newItem, hand).postAndCatch()
InventoryUtils.recentItemsInHand.keys.removeIf { it + 30_000 > System.currentTimeMillis() }
- if (newItem != "") {
+ if (newItem != NEUInternalName.NONE) {
InventoryUtils.recentItemsInHand[System.currentTimeMillis()] = newItem
}
InventoryUtils.itemInHandId = newItem
@@ -86,7 +87,7 @@ class MinecraftData {
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
- InventoryUtils.itemInHandId = ""
+ InventoryUtils.itemInHandId = NEUInternalName.NONE
InventoryUtils.recentItemsInHand.clear()
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/ItemInHandChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ItemInHandChangeEvent.kt
index 121e7d9cd..3f5b94b3c 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/ItemInHandChangeEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/ItemInHandChangeEvent.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.events
+import at.hannibal2.skyhanni.utils.NEUInternalName
import net.minecraft.item.ItemStack
-class ItemInHandChangeEvent(val internalName: String, val stack: ItemStack?) : LorenzEvent() \ No newline at end of file
+class ItemInHandChangeEvent(val internalName: NEUInternalName, val stack: ItemStack?) : LorenzEvent() \ No newline at end of file
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
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
index dc36a5b0e..1cd9abdc8 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
@@ -7,8 +7,8 @@ import net.minecraft.inventory.Slot
import net.minecraft.item.ItemStack
object InventoryUtils {
- var itemInHandId = ""
- var recentItemsInHand = mutableMapOf<Long, String>()
+ var itemInHandId = NEUInternalName.NONE
+ var recentItemsInHand = mutableMapOf<Long, NEUInternalName>()
var latestItemInHand: ItemStack? = null
fun getItemsInOpenChest() = buildList<Slot> {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 8fe41bfb2..c055ff42b 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -120,7 +120,7 @@ object ItemUtils {
// TODO remove
fun ItemStack.getInternalName_old() = getInternalName().asString()
- fun ItemStack.getInternalName() = getInternalNameOrNull() ?: "".asInternalName()
+ fun ItemStack.getInternalName() = getInternalNameOrNull() ?: NEUInternalName.NONE
fun ItemStack.getInternalNameOrNull() = getRawInternalName()?.asInternalName()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
index 5ccb74664..acf2aa092 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
@@ -5,6 +5,9 @@ class NEUInternalName private constructor(private val internalName: String) {
companion object {
private val map = mutableMapOf<String, NEUInternalName>()
+ val NONE = "NONE".asInternalName()
+ val MISSING_ITEM = "MISSING_ITEM".asInternalName()
+
fun String.asInternalName(): NEUInternalName {
val internalName = uppercase()
return map.getOrPut(internalName) { NEUInternalName(internalName) }
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index f55277e0a..d530e79df 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -93,9 +93,8 @@ object NEUItems {
}
if (itemName == "§cmissing repo item") {
- val name = "MISSING_ITEM".asInternalName()
- itemNameCache[lowercase] = name
- return name
+ itemNameCache[lowercase] = NEUInternalName.MISSING_ITEM
+ return NEUInternalName.MISSING_ITEM
}
resolveEnchantmentByName(itemName)?.let {