aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-11 12:43:44 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-11 12:43:44 +0200
commitc3caf0b538747d46d02f38a2d2182c821ef1b0f0 (patch)
tree0937fa184e3cbd7f03f41a9b037446db61673e6e /src/main/java/at/hannibal2/skyhanni/features
parenteaa9df9d3242d3df86000d302f38bc73fa941db4 (diff)
downloadskyhanni-c3caf0b538747d46d02f38a2d2182c821ef1b0f0.tar.gz
skyhanni-c3caf0b538747d46d02f38a2d2182c821ef1b0f0.tar.bz2
skyhanni-c3caf0b538747d46d02f38a2d2182c821ef1b0f0.zip
Added support for lower case names and common typos in /shtrackcollection
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt57
2 files changed, 47 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt
index d181caa3a..d5b1c5144 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt
@@ -183,7 +183,7 @@ class BingoNextStepHelper {
}
}
if (step is CollectionStep) {
- val counter = CollectionAPI.getCollectionCounter(step.collectionName)?.second ?: 0
+ val counter = CollectionAPI.getCollectionCounter(step.collectionName) ?: 0
if (step.amountHaving != counter) {
step.amountHaving = counter
if (counter >= step.amountNeeded) {
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 b7d7b52f1..8915ff071 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt
@@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraft.client.Minecraft
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -41,25 +42,59 @@ class CollectionCounter {
return
}
- val name = args.joinToString(" ").replace(" ", "_")
- val pair = CollectionAPI.getCollectionCounter(name)
- if (pair == 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)")
+ val rawName = fixTypo(args.joinToString(" ").lowercase())
+ if (rawName == "gemstone") {
+ LorenzUtils.chat("§c[SkyHanni] Gemstone collection is not supported!")
+// setNewCollection("GEMSTONE_COLLECTION", "Gemstone")
+ return
+ } else if (rawName == "mushroom") {
+ LorenzUtils.chat("§c[SkyHanni] Mushroom collection is not supported!")
+// setNewCollection("MUSHROOM_COLLECTION", "Mushroom")
return
}
- internalName = pair.first
- if (internalName.contains("MUSHROOM") || internalName.endsWith("_GEM")) {
- LorenzUtils.chat("§7Mushroom and Gemstone items are not fully supported for the counter!")
- internalName = ""
+ val foundInternalName = NEUItems.getInternalNameOrNullIgnoreCase(rawName) ?: rawName.replace(" ", "_")
+ val stack = NEUItems.getItemStackOrNull(foundInternalName)
+ if (stack == null) {
+ LorenzUtils.chat("§c[SkyHanni] Item '$rawName' does not exist!")
+ return
+ }
+ setNewCollection(foundInternalName, stack.name!!.removeColor())
+ }
+
+ private fun fixTypo(rawName: String) = when (rawName) {
+ "carrot" -> "carrots"
+ "melons" -> "melon"
+ "seed" -> "seeds"
+ "iron" -> "iron ingot"
+ "gold" -> "gold ingot"
+ "sugar" -> "sugar cane"
+ "cocoa bean", "cocoa" -> "cocoa beans"
+ "lapis" -> "lapis lazuli"
+ "cacti" -> "cactus"
+ "pumpkins" -> "pumpkin"
+ "potatoes" -> "potato"
+ "nether warts", "wart", "warts" -> "nether wart"
+ "stone" -> "cobblestone"
+ "red mushroom", "brown mushroom", "mushrooms" -> "mushroom"
+ "gemstones" -> "gemstone"
+
+ else -> rawName
+ }
+
+ private fun setNewCollection(internalName: String, 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)")
return
}
- itemName = NEUItems.getItemStack(internalName).name!!
- itemAmount = pair.second
+ this.internalName = internalName
+ itemName = name
+ itemAmount = foundAmount
lastAmountInInventory = countCurrentlyInInventory()
updateDisplay()
- LorenzUtils.chat("§e[SkyHanni] Started tracking $itemName collection.")
+ LorenzUtils.chat("§e[SkyHanni] Started tracking $itemName §ecollection.")
}
private fun resetData() {