aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/VanillaItemManager.kt51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/VanillaItemManager.kt b/src/main/java/at/hannibal2/skyhanni/data/VanillaItemManager.kt
deleted file mode 100644
index f2bcd51ca..000000000
--- a/src/main/java/at/hannibal2/skyhanni/data/VanillaItemManager.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-package at.hannibal2.skyhanni.data
-
-import com.google.gson.GsonBuilder
-import com.google.gson.JsonObject
-import java.io.BufferedReader
-import java.io.File
-import java.io.FileInputStream
-import java.io.InputStreamReader
-import java.nio.charset.StandardCharsets
-
-object VanillaItemManager {
- private val gson = GsonBuilder().setPrettyPrinting().create()
-
- private val vanillaItems: MutableList<String> = ArrayList()
-
- fun isVanillaItem(internalName: String): Boolean {
- return vanillaItems.contains(internalName)
- }
-
- init {
- load()
- }
-
- private fun load() {
- vanillaItems.clear()
- val itemDirectory = File("config/notenoughupdates/repo/items")
- if (!itemDirectory.isDirectory) return
- val files = itemDirectory.listFiles() ?: return
- for (file in files) {
- val jsonObject = getJsonFromFile(file)
- if (jsonObject != null) {
- if (jsonObject.has("vanilla") && jsonObject["vanilla"].asBoolean) {
- val name = file.name
- val internalName = name.split(".")[0]
- vanillaItems.add(internalName)
- }
- }
- }
-
- }
-
- private fun getJsonFromFile(file: File): JsonObject? {
- try {
- BufferedReader(
- InputStreamReader(FileInputStream(file), StandardCharsets.UTF_8)
- ).use { reader -> return gson.fromJson(reader, JsonObject::class.java) }
- } catch (e: Exception) {
- return null
- }
- }
-} \ No newline at end of file