aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-26 15:46:54 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-26 15:46:54 +0100
commita5540841c951f2f694cf48f8dd093f69e9d36c44 (patch)
treebfe652984b93789a98e699793baf16776acb9fdc /src/main/java/at/hannibal2
parent69b7a4688ed84b89b21545ebb382cf8a4f57307c (diff)
downloadskyhanni-a5540841c951f2f694cf48f8dd093f69e9d36c44.tar.gz
skyhanni-a5540841c951f2f694cf48f8dd093f69e9d36c44.tar.bz2
skyhanni-a5540841c951f2f694cf48f8dd093f69e9d36c44.zip
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingTrackerCategoryManager.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt4
8 files changed, 23 insertions, 22 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 a7dd3e845..241d208a3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
@@ -39,7 +39,7 @@ class BazaarApi {
holder.getData(this)
} else null
- fun isBazaarItem(stack: ItemStack) = stack.getInternalName().isBazaarItem()
+ fun isBazaarItem(stack: ItemStack): Boolean = stack.getInternalName().isBazaarItem()
fun NEUInternalName.isBazaarItem() = NEUItems.manager.auctionManager.getBazaarInfo(asString()) != null
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
index 9dab12e79..671b42848 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt
@@ -18,7 +18,6 @@ import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
import net.minecraft.client.Minecraft
import net.minecraft.item.ItemStack
@@ -145,7 +144,7 @@ class MinionCraftHelper {
allIngredients.clear()
- for (internalId in NotEnoughUpdates.INSTANCE.manager.itemInformation.keys) {
+ for (internalId in NEUItems.allNeuRepoItems().keys) {
val internalName = internalId.asInternalName()
if (internalName.endsWith("_GENERATOR_1")) {
if (internalName == "REVENANT_GENERATOR_1".asInternalName() ||
diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt
index 147775fed..c486f6f50 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt
@@ -22,7 +22,7 @@ object ViewRecipeCommand {
val list by lazy {
val list = mutableListOf<String>()
- for ((key, value) in NEUItems.manager.itemInformation) {
+ for ((key, value) in NEUItems.allNeuRepoItems()) {
if (value.has("recipe")) {
list.add(key.lowercase())
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingTrackerCategoryManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingTrackerCategoryManager.kt
index 2006975ad..8c240799f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingTrackerCategoryManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingTrackerCategoryManager.kt
@@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.FishingProfitItemsJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates
+import at.hannibal2.skyhanni.utils.NEUItems
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object FishingTrackerCategoryManager {
@@ -28,7 +28,7 @@ object FishingTrackerCategoryManager {
fun onNeuRepoReload(event: io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent) {
val totalDrops = mutableListOf<String>()
val dropCategories = mutableMapOf<String, MutableList<NEUInternalName>>()
- for ((seaCreature, data) in NotEnoughUpdates.INSTANCE.manager.itemInformation.filter { it.key.endsWith("_SC") }) {
+ for ((seaCreature, data) in NEUItems.allNeuRepoItems().filter { it.key.endsWith("_SC") }) {
val asJsonObject = data.getAsJsonArray("recipes")[0].asJsonObject
val drops = asJsonObject.getAsJsonArray("drops")
.map { it.asJsonObject.get("id").asString }.map { it.split(":").first() }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
index 0b695149b..c9ff17c5b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt
@@ -45,7 +45,6 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.renderables.Renderable
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.Collections
@@ -551,7 +550,7 @@ object ComposterOverlay {
private fun updateOrganicMatterFactors(baseValues: Map<NEUInternalName, Double>): Map<NEUInternalName, Double> {
val map = mutableMapOf<NEUInternalName, Double>()
- for ((internalName, _) in NotEnoughUpdates.INSTANCE.manager.itemInformation) {
+ for ((internalName, _) in NEUItems.allNeuRepoItems()) {
if (internalName == "POTION_AFFINITY_TALISMAN"
|| internalName == "CROPIE_TALISMAN"
|| internalName.endsWith("_BOOTS")
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 e46b9e56e..9c3d91065 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
@@ -398,7 +398,7 @@ object CropMoneyDisplay {
SkyHanniMod.coroutineScope.launch {
val map = mutableMapOf<NEUInternalName, Int>()
- for ((rawInternalName, _) in NEUItems.manager.itemInformation) {
+ for ((rawInternalName, _) in NEUItems.allNeuRepoItems()) {
if (rawInternalName == "ENCHANTED_PAPER") continue
if (rawInternalName == "ENCHANTED_BREAD") continue
if (rawInternalName == "SIMPLE_CARROT_CANDY") continue
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index ba23b2624..ad2df542c 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -78,7 +78,7 @@ object NEUItems {
fun readAllNeuItems(): Map<String, NEUInternalName> {
allInternalNames.clear()
val map = mutableMapOf<String, NEUInternalName>()
- for (rawInternalName in manager.itemInformation.keys) {
+ for (rawInternalName in allNeuRepoItems().keys) {
val name = manager.createItem(rawInternalName).displayName.removeColor().lowercase()
val internalName = rawInternalName.asInternalName()
map[name] = internalName
@@ -133,12 +133,12 @@ object NEUItems {
return text
}
- fun getInternalName(itemStack: ItemStack) = ItemResolutionQuery(manager)
+ fun getInternalName(itemStack: ItemStack): String? = ItemResolutionQuery(manager)
.withCurrentGuiContext()
.withItemStack(itemStack)
.resolveInternalName()
- fun getInternalNameOrNull(nbt: NBTTagCompound) =
+ fun getInternalNameOrNull(nbt: NBTTagCompound): NEUInternalName? =
ItemResolutionQuery(manager).withItemNBT(nbt).resolveInternalName()?.asInternalName()
fun NEUInternalName.getPrice(useSellingPrice: Boolean = false) = getPriceOrNull(useSellingPrice) ?: -1.0
@@ -152,7 +152,7 @@ object NEUItems {
return BazaarDataHolder.getNpcPrice(this)
}
- fun transHypixelNameToInternalName(hypixelId: String) =
+ fun transHypixelNameToInternalName(hypixelId: String): NEUInternalName =
manager.auctionManager.transformHypixelBazaarToNEUItemId(hypixelId).asInternalName()
fun NEUInternalName.getPriceOrNull(useSellingPrice: Boolean = false): Double? {
@@ -172,10 +172,10 @@ object NEUItems {
return getNpcPriceOrNull()
}
- fun getPrice(internalName: String, useSellingPrice: Boolean = false) =
+ fun getPrice(internalName: String, useSellingPrice: Boolean = false): Double =
internalName.asInternalName().getPrice(useSellingPrice)
- fun NEUInternalName.getItemStackOrNull() = ItemResolutionQuery(manager)
+ fun NEUInternalName.getItemStackOrNull(): ItemStack? = ItemResolutionQuery(manager)
.withKnownInternalName(asString())
.resolveToItemStack()?.copy()
@@ -192,13 +192,14 @@ object NEUItems {
ErrorManager.logError(
IllegalStateException("Something went wrong!"),
"Encountered an error getting the item for §7$this§c. " +
- "This may be because your NEU repo is outdated. Please ask in the SkyHanni " +
- "Discord if this is the case"
+ "This may be because your NEU repo is outdated. Please ask in the SkyHanni " +
+ "Discord if this is the case"
)
fallbackItem
}
- fun isVanillaItem(item: ItemStack) = manager.auctionManager.isVanillaItem(item.getInternalName().asString())
+ fun isVanillaItem(item: ItemStack): Boolean =
+ manager.auctionManager.isVanillaItem(item.getInternalName().asString())
fun ItemStack.renderOnScreen(x: Float, y: Float, scaleMultiplier: Double = 1.0) {
val item = checkBlinkItem()
@@ -230,6 +231,8 @@ object NEUItems {
GlStateManager.popMatrix()
}
+ fun allNeuRepoItems(): Map<String, JsonObject> = NotEnoughUpdates.INSTANCE.manager.itemInformation
+
fun getMultiplier(internalName: NEUInternalName, tryCount: Int = 0): Pair<NEUInternalName, Int> {
if (multiplierCache.contains(internalName)) {
return multiplierCache[internalName]!!
@@ -323,8 +326,8 @@ object NEUItems {
val name = group("name").trim { it <= ' ' }
val ultimate = group("format").lowercase().contains("§l")
((if (ultimate && name != "Ultimate Wise") "ULTIMATE_" else "")
- + turboCheck(name).replace(" ", "_").replace("-", "_").uppercase()
- + ";" + group("level").romanToDecimal())
+ + turboCheck(name).replace(" ", "_").replace("-", "_").uppercase()
+ + ";" + group("level").romanToDecimal())
}
//Uses NEU
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt
index 68aebd04e..9cb7457ff 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt
@@ -55,7 +55,7 @@ object RenderLineTooltips {
}
if (needsWrap) {
var wrappedTooltipWidth = 0
- val wrappedTextLines: MutableList<String?> = ArrayList()
+ val wrappedTextLines = mutableListOf<String>()
for (i in textLines.indices) {
val textLine = textLines[i]
val wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth)
@@ -230,4 +230,4 @@ object RenderLineTooltips {
GlStateManager.enableAlpha()
GlStateManager.enableTexture2D()
}
-} \ No newline at end of file
+}