aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-02-25 21:44:13 +1100
committerGitHub <noreply@github.com>2024-02-25 11:44:13 +0100
commit2a8edee6275a4abe3375351455c27d2ee56f9c36 (patch)
treec92a63bcd9e8c2614beef7cbeb83d97247a6d3c0 /src/main/java
parent190d97aeb18bbb02778b206404d7084c648038dd (diff)
downloadskyhanni-2a8edee6275a4abe3375351455c27d2ee56f9c36.tar.gz
skyhanni-2a8edee6275a4abe3375351455c27d2ee56f9c36.tar.bz2
skyhanni-2a8edee6275a4abe3375351455c27d2ee56f9c36.zip
/gfs tab complete now uses NEU's Repo instead of SkyHanni Repo. #1053
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt33
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/NeuSacksJson.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SacksJson.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt3
8 files changed, 67 insertions, 27 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
index be1694a86..53cab5d02 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
@@ -1,20 +1,20 @@
package at.hannibal2.skyhanni.api
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.jsonobjects.repo.SacksJson
+import at.hannibal2.skyhanni.config.ConfigManager
+import at.hannibal2.skyhanni.data.jsonobjects.other.NeuSacksJson
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
-import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.features.commands.tabcomplete.GetFromSacksTabComplete
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ChatUtils.isCommand
import at.hannibal2.skyhanni.utils.ChatUtils.senderIsSkyhanni
-import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
@@ -25,7 +25,9 @@ import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveSta
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.fromJson
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import io.github.moulberry.notenoughupdates.util.Utils
import net.minecraft.inventory.Slot
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.Deque
@@ -222,12 +224,27 @@ object GetFromSackAPI {
}
@SubscribeEvent
- fun onRepoReload(event: RepositoryReloadEvent) {
- sackListInternalNames = event.getConstant<SacksJson>("Sacks").sackItems.toSet()
+ fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
+ val data = event.getConstant("sacks") ?: ErrorManager.skyHanniError("NEU sacks data is null.")
+ try {
+ val sacksData = ConfigManager.gson.fromJson<NeuSacksJson>(data).sacks
+ val uniqueSackItems = mutableSetOf<NEUInternalName>()
+
+ sacksData.values.forEach { sackInfo ->
+ sackInfo.contents.forEach { content ->
+ uniqueSackItems.add(content)
+ }
+ }
+
+ sackListInternalNames = uniqueSackItems.map { it.asString() }.toSet()
+ sackListNames = uniqueSackItems.map { it.itemNameWithoutColor.uppercase() }.toSet()
- DelayedRun.runNextTick {
- sackListNames = sackListInternalNames.map { it.asInternalName().itemNameWithoutColor.uppercase() }.toSet()
+ } catch (e: Exception) {
+ ErrorManager.logErrorWithData(
+ e, "Error getting NEU sacks data, make sure your neu repo is updated.",
+ "sacksJson" to data
+ )
+ Utils.showOutdatedRepoNotification()
}
- //sackListNames = event.getConstant<SacksJson>("Sacks").sackList.map { it.uppercase() }.toSet()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/NeuSacksJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/NeuSacksJson.kt
new file mode 100644
index 000000000..c323211fb
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/NeuSacksJson.kt
@@ -0,0 +1,14 @@
+package at.hannibal2.skyhanni.data.jsonobjects.other
+
+import at.hannibal2.skyhanni.utils.NEUInternalName
+import com.google.gson.annotations.Expose
+
+
+data class NeuSacksJson(
+ @Expose val sacks: Map<String, SackInfo>
+)
+
+data class SackInfo(
+ @Expose val item: NEUInternalName,
+ @Expose val contents: List<NEUInternalName>
+)
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SacksJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SacksJson.java
index a2c6dc66e..e8bb83a79 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SacksJson.java
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SacksJson.java
@@ -9,7 +9,4 @@ public class SacksJson {
@Deprecated
@Expose
public List<String> sackList;
-
- @Expose
- public List<String> sackItems;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt
index 021dd183b..19fba633b 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.data.repo
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
+import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
@@ -279,4 +280,9 @@ class RepoManager(private val configLocation: File) {
)
).use { writer -> writer.write(gson.toJson(json)) }
}
+
+ @SubscribeEvent
+ fun onNeuRepoReload(event: io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent) {
+ NeuRepositoryReloadEvent().postAndCatch()
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt
new file mode 100644
index 000000000..a162a8973
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt
@@ -0,0 +1,11 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.utils.NEUItems.manager
+import com.google.gson.JsonObject
+import java.io.File
+
+class NeuRepositoryReloadEvent : LorenzEvent() {
+ fun getConstant(file: String): JsonObject? {
+ return manager.getJsonFromFile(File(manager.repoLocation, "constants/$file.json"))
+ }
+}
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 7c0987883..08e6382c1 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
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.features.bazaar.BazaarApi
@@ -533,7 +534,7 @@ object ComposterOverlay {
}
@SubscribeEvent
- fun onRepoReload(event: io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent) {
+ fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
updateOrganicMatterFactors()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
index 977d041fa..2d6c37469 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.events.RenderItemTooltipEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
@@ -25,7 +26,6 @@ import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
-import at.hannibal2.skyhanni.utils.NEUItems.manager
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
@@ -35,7 +35,6 @@ import net.minecraft.client.Minecraft
import net.minecraft.init.Items
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import java.io.File
import kotlin.math.roundToLong
object EstimatedItemValue {
@@ -51,18 +50,12 @@ object EstimatedItemValue {
fun isCurrentlyShowing() = currentlyShowing && Minecraft.getMinecraft().currentScreen != null
@SubscribeEvent
- fun onRepoReload(event: io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent) {
- val data = manager.getJsonFromFile(File(manager.repoLocation, "constants/gemstonecosts.json"))
-
- if (data != null)
- // item_internal_names -> gemstone_slots -> ingredients_array
- gemstoneUnlockCosts =
- ConfigManager.gson.fromJson(
- data,
- object : TypeToken<HashMap<NEUInternalName, HashMap<String, List<String>>>>() {}.type
- )
- else
- ChatUtils.error("Gemstone Slot Unlock Costs failed to load!")
+ fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
+ val data = event.getConstant("gemstonecosts") ?: run {
+ ErrorManager.skyHanniError("Gemstone Slot Unlock Costs failed to load from neu repo!")
+ }
+
+ gemstoneUnlockCosts = ConfigManager.gson.fromJson(data, object : TypeToken<HashMap<NEUInternalName, HashMap<String, List<String>>>>() {}.type)
}
@SubscribeEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt
index 53a030f88..62bb84b94 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -45,7 +46,7 @@ class HighlightMissingRepoItems {
}
@SubscribeEvent
- fun onNeuRepoReload(event: io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent) {
+ fun onNeuRepoReload(event: NeuRepositoryReloadEvent) {
NEUItems.allItemsCache = NEUItems.readAllNeuItems()
}