summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt50
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/PlayerTabComplete.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/TabComplete.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftAPI.kt7
7 files changed, 70 insertions, 40 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 52227e4f7..1d9c20dea 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt
@@ -2,13 +2,10 @@ 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
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
-import at.hannibal2.skyhanni.utils.LorenzColor
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.NEUItems
-import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.gui.inventory.GuiChest
@@ -27,14 +24,19 @@ class BazaarApi {
fun getBazaarDataByName(name: String): BazaarData? =
NEUItems.getInternalNameOrNull(name)?.let { getBazaarDataByInternalName(it) }
- fun getBazaarDataByInternalName(internalName: String): BazaarData? {
- return if (isBazaarItem(internalName)) {
+ fun getBazaarDataByInternalName(internalName: String) =
+ getBazaarDataByInternalName_new(NEUInternalName.from(internalName))
+
+ fun getBazaarDataByInternalName_new(internalName: NEUInternalName) = if (isBazaarItem(internalName)) {
holder.getData(internalName)
} else null
- }
fun isBazaarItem(stack: ItemStack) = isBazaarItem(stack.getInternalName())
+ fun isBazaarItem(internalName: NEUInternalName): Boolean {
+ return NEUItems.manager.auctionManager.getBazaarInfo(internalName.asString()) != null
+ }
+
fun isBazaarItem(internalName: String): Boolean {
return NEUItems.manager.auctionManager.getBazaarInfo(internalName) != null
}
@@ -91,7 +93,9 @@ class BazaarApi {
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
- if ("\\[Bazaar] (Buy Order Setup!|Bought).*$currentSearchedItem.*".toRegex().matches(event.message.removeColor())) {
+ if ("\\[Bazaar] (Buy Order Setup!|Bought).*$currentSearchedItem.*".toRegex()
+ .matches(event.message.removeColor())
+ ) {
currentSearchedItem = ""
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt
index e9511d1b1..3562be68a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.features.bazaar
data class BazaarData(
- val apiName: String,
val displayName: String,
val sellPrice: Double,
val buyPrice: Double,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt
index 53ae2935e..c6d31cede 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataHolder.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.features.rift.everywhere.RiftAPI
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import kotlinx.coroutines.launch
@@ -13,15 +14,15 @@ import kotlin.concurrent.fixedRateTimer
class BazaarDataHolder {
companion object {
- private val bazaarData = mutableMapOf<String, BazaarData>()
- private var npcPrices = mapOf<String, Double>()
+ private val bazaarData = mutableMapOf<NEUInternalName, BazaarData>()
+ private var npcPrices = mapOf<NEUInternalName, Double>()
}
- private fun loadNpcPrices(): MutableMap<String, Double> {
- val list = mutableMapOf<String, Double>()
+ private fun loadNpcPrices(): MutableMap<NEUInternalName, Double> {
+ val list = mutableMapOf<NEUInternalName, Double>()
try {
val itemsData = APIUtil.getJSONResponse("https://api.hypixel.net/resources/skyblock/items")
- val motesPrice = mutableMapOf<String, Double>()
+ val motesPrice = mutableMapOf<NEUInternalName, Double>()
for (element in itemsData["items"].asJsonArray) {
val jsonObject = element.asJsonObject
val hypixelId = jsonObject["id"].asString
@@ -52,10 +53,10 @@ class BazaarDataHolder {
}
}
- fun getData(internalName: String) = bazaarData[internalName] ?: createNewData(internalName)
+ fun getData(internalName: NEUInternalName) = bazaarData[internalName] ?: createNewData(internalName)
- private fun createNewData(internalName: String): BazaarData? {
- val stack = NEUItems.getItemStackOrNull(internalName)
+ private fun createNewData(internalName: NEUInternalName): BazaarData? {
+ val stack = NEUItems.getItemStackOrNull(internalName.asString())
if (stack == null) {
LorenzUtils.debug("Bazaar data is null: '$internalName'")
return null
@@ -65,14 +66,14 @@ class BazaarDataHolder {
val buyPrice = NEUItems.getPrice(internalName, false)
val npcPrice = npcPrices[internalName].let {
if (it == null) {
- if (!ignoreNoNpcPrice(internalName)) {
+ if (!ignoreNoNpcPrice(internalName.asString())) {
LorenzUtils.debug("NPC price not found for item '$internalName'")
}
0.0
} else it
}
- val data = BazaarData(internalName, displayName, sellPrice, buyPrice, npcPrice)
+ val data = BazaarData(displayName, sellPrice, buyPrice, npcPrice)
bazaarData[internalName] = data
return data
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt
index ef23583e3..ff860b3b5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt
@@ -5,14 +5,16 @@ import at.hannibal2.skyhanni.api.CollectionAPI
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_new
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems
-import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.*
class CollectionCounter {
@@ -20,10 +22,10 @@ class CollectionCounter {
companion object {
- private var display = ""
+ private var display = emptyList<List<Any>>()
private var itemName = ""
- private var internalName = ""
+ private var internalName: NEUInternalName? = null
private var itemAmount = -1L
private var lastAmountInInventory = -1
@@ -33,7 +35,7 @@ class CollectionCounter {
fun command(args: Array<String>) {
if (args.isEmpty()) {
- if (internalName == "") {
+ if (internalName == null) {
LorenzUtils.chat("§c/shtrackcollection <item name>")
return
}
@@ -42,7 +44,7 @@ class CollectionCounter {
return
}
- val rawName = fixTypo(args.joinToString(" ").lowercase())
+ val rawName = fixTypo(args.joinToString(" ").lowercase().replace("_", " "))
if (rawName == "gemstone") {
LorenzUtils.chat("§c[SkyHanni] Gemstone collection is not supported!")
// setNewCollection("GEMSTONE_COLLECTION", "Gemstone")
@@ -53,7 +55,13 @@ class CollectionCounter {
return
}
- val foundInternalName = NEUItems.getInternalNameOrNullIgnoreCase(rawName) ?: rawName.replace(" ", "_")
+// val foundInternalName = NEUItems.getInternalNameOrNullIgnoreCase(rawName) ?: rawName.replace(" ", "_")
+ val foundInternalName = NEUItems.getInternalNameOrNullIgnoreCase(rawName)
+ if (foundInternalName == null) {
+ LorenzUtils.chat("§c[SkyHanni] Item '$rawName' does not exist!")
+ return
+ }
+
val stack = NEUItems.getItemStackOrNull(foundInternalName)
if (stack == null) {
LorenzUtils.chat("§c[SkyHanni] Item '$rawName' does not exist!")
@@ -63,7 +71,7 @@ class CollectionCounter {
}
private fun fixTypo(rawName: String) = when (rawName) {
- "carrot" -> "carrots"
+ "carrots" -> "carrot"
"melons" -> "melon"
"seed" -> "seeds"
"iron" -> "iron ingot"
@@ -78,11 +86,13 @@ class CollectionCounter {
"stone" -> "cobblestone"
"red mushroom", "brown mushroom", "mushrooms" -> "mushroom"
"gemstones" -> "gemstone"
+ "caducous" -> "caducous stem"
+ "agaricus" -> "agaricus cap"
else -> rawName
}
- private fun setNewCollection(internalName: String, name: String) {
+ private fun setNewCollection(internalName: NEUInternalName, name: String) {
val foundAmount = CollectionAPI.getCollectionCounter(internalName)
if (foundAmount == null) {
LorenzUtils.chat("§c[SkyHanni] Item $name is not in the collection data! (Maybe the API is disabled or try to open the collection inventory)")
@@ -99,10 +109,10 @@ class CollectionCounter {
private fun resetData() {
itemAmount = -1
- internalName = ""
+ internalName = null
lastAmountInInventory = -1
- display = ""
+ display = emptyList()
recentGain = 0
}
@@ -115,11 +125,23 @@ class CollectionCounter {
gainText = "§a+" + LorenzUtils.formatInteger(recentGain)
}
- display = "$itemName collection: §e$format $gainText"
+ display = Collections.singletonList(buildList {
+ internalName?.let {
+ add(NEUItems.getItemStack(it))
+ }
+ add("$itemName collection: §e$format $gainText")
+ })
}
private fun countCurrentlyInInventory() =
- InventoryUtils.countItemsInLowerInventory { it.getInternalName() == internalName }
+ InventoryUtils.countItemsInLowerInventory { it.getInternalName_new() == internalName }
+
+ fun handleTabComplete(command: String): List<String>? {
+ if (command != "shtrackcollection") return null
+
+ return CollectionAPI.collectionValue.keys.mapNotNull { NEUItems.getItemStackOrNull(it) }
+ .map { it.displayName.removeColor().replace(" ", "_") }
+ }
}
@SubscribeEvent
@@ -171,6 +193,6 @@ class CollectionCounter {
fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
if (!LorenzUtils.inSkyBlock) return
- SkyHanniMod.feature.misc.collectionCounterPos.renderString(display, posLabel = "Collection Counter")
+ SkyHanniMod.feature.misc.collectionCounterPos.renderStringsAndItems(display, posLabel = "Collection Counter")
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/PlayerTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/PlayerTabComplete.kt
index 66029a4ee..5bf74e44c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/PlayerTabComplete.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/PlayerTabComplete.kt
@@ -25,7 +25,7 @@ object PlayerTabComplete {
ISLAND_PLAYERS,
}
- fun handleTabComplete(command: String, originalArray: Array<String>): List<String>? {
+ fun handleTabComplete(command: String): List<String>? {
val commands = mapOf(
"p" to listOf(PlayerCategory.PARTY),
"party" to listOf(PlayerCategory.PARTY),
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/TabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/TabComplete.kt
index 388b89034..08ec84c52 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/TabComplete.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/TabComplete.kt
@@ -1,5 +1,7 @@
package at.hannibal2.skyhanni.features.misc.tabcomplete
+import at.hannibal2.skyhanni.features.misc.CollectionCounter
+
object TabComplete {
@JvmStatic
@@ -9,7 +11,7 @@ object TabComplete {
var command = splits.first().lowercase()
if (command.startsWith("/")) {
command = command.substring(1)
- customTabComplete(command, originalArray)?.let {
+ customTabComplete(command)?.let {
return buildResponse(splits, it).toSet().toTypedArray()
}
}
@@ -17,9 +19,10 @@ object TabComplete {
return null
}
- private fun customTabComplete(command: String, originalArray: Array<String>): List<String>? {
+ private fun customTabComplete(command: String): List<String>? {
WarpTabComplete.handleTabComplete(command)?.let { return it }
- PlayerTabComplete.handleTabComplete(command, originalArray)?.let { return it }
+ PlayerTabComplete.handleTabComplete(command)?.let { return it }
+ CollectionCounter.handleTabComplete(command)?.let { return it }
return null
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftAPI.kt
index 20e64dc8f..4e500d21f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftAPI.kt
@@ -3,8 +3,9 @@ package at.hannibal2.skyhanni.features.rift.everywhere
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.features.RiftConfig
import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_new
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUInternalName
import net.minecraft.item.ItemStack
object RiftAPI {
@@ -13,10 +14,10 @@ object RiftAPI {
val config: RiftConfig get() = SkyHanniMod.feature.rift
// internal name -> motes
- var motesPrice = emptyMap<String, Double>()
+ var motesPrice = emptyMap<NEUInternalName, Double>()
fun ItemStack.motesNpcPrice(): Double? {
- val baseMotes = motesPrice[getInternalName()] ?: return null
+ val baseMotes = motesPrice[getInternalName_new()] ?: return null
val burgerStacks = config.motes.burgerStacks
val pricePer = baseMotes + (burgerStacks * 5) * baseMotes / 100
return pricePer * stackSize