diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 69687535b..b78a23c0d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -1,10 +1,13 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.utils.ItemBlink.checkBlinkItem import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import com.google.gson.JsonObject +import com.google.gson.JsonPrimitive import io.github.moulberry.notenoughupdates.NEUManager import io.github.moulberry.notenoughupdates.NEUOverlay import io.github.moulberry.notenoughupdates.NotEnoughUpdates @@ -268,4 +271,23 @@ object NEUItems { + ";" + group("level").romanToDecimal()) } } + + //Uses NEU + fun saveNBTData(item: ItemStack, removeLore: Boolean = true): String { + val jsonObject = manager.getJsonForItem(item) + if (!jsonObject.has("internalname")) { + jsonObject.add("internalname", JsonPrimitive("_")) + } + if (removeLore) { + if (jsonObject.has("lore")) jsonObject.remove("lore") + } + val jsonString = jsonObject.toString() + return StringUtils.encodeBase64(jsonString) + } + + fun loadNBTData(encoded: String): ItemStack { + val jsonString = StringUtils.decodeBase64(encoded) + val jsonObject = ConfigManager.gson.fromJson(jsonString, JsonObject::class.java) + return manager.jsonToStack(jsonObject, false) + } }
\ No newline at end of file |