diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-09-13 20:23:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-13 20:23:40 +0200 |
commit | 691d2551cf722b76c1894c814d1f6c2e98fe17d6 (patch) | |
tree | c02fd9edb6c2f1f4cb8791cf7113c8d5a8594a2f /src/main/java/at/hannibal2/skyhanni/utils | |
parent | 20081af74fd53f35746ab0d5c974bb5db92bec3b (diff) | |
download | skyhanni-691d2551cf722b76c1894c814d1f6c2e98fe17d6.tar.gz skyhanni-691d2551cf722b76c1894c814d1f6c2e98fe17d6.tar.bz2 skyhanni-691d2551cf722b76c1894c814d1f6c2e98fe17d6.zip |
Feature: Carnival QoL (#2498)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
3 files changed, 22 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt index 176afe8c0..c148e93e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt @@ -32,6 +32,10 @@ object HypixelCommands { send("recipe $itemName") } + fun npcOption(npc: String, answer: String) { + send("selectnpcoption $npc $answer") + } + fun warp(warp: String) { send("warp $warp") } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt index bc9f706f8..5b3e8c8e1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import com.google.gson.GsonBuilder import io.github.notenoughupdates.moulconfig.observer.PropertyTypeAdapterFactory import net.minecraft.item.ItemStack +import java.time.LocalDate import java.util.UUID object BaseGsonBuilder { @@ -28,9 +29,10 @@ object BaseGsonBuilder { .registerTypeAdapter(IslandType::class.java, SkyHanniTypeAdapters.ISLAND_TYPE.nullSafe()) .registerTypeAdapter( SkyHanniTracker.DefaultDisplayMode::class.java, - SkyHanniTypeAdapters.TRACKER_DISPLAY_MODE.nullSafe() + SkyHanniTypeAdapters.TRACKER_DISPLAY_MODE.nullSafe(), ) .registerTypeAdapter(SimpleTimeMark::class.java, SkyHanniTypeAdapters.TIME_MARK.nullSafe()) + .registerTypeAdapter(LocalDate::class.java, SkyHanniTypeAdapters.LOCALE_DATE.nullSafe()) .enableComplexMapKeySerialization() fun lenientGson(): GsonBuilder = gson() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt index 7859853ca..2048be522 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt @@ -18,9 +18,11 @@ import com.google.gson.TypeAdapter import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonWriter import net.minecraft.item.ItemStack +import java.time.LocalDate import java.util.UUID object SkyHanniTypeAdapters { + val NEU_ITEMSTACK: TypeAdapter<ItemStack> = SimpleStringTypeAdapter(NEUItems::saveNBTData, NEUItems::loadNBTData) val UUID: TypeAdapter<UUID> = SimpleStringTypeAdapter( @@ -72,7 +74,19 @@ object SkyHanniTypeAdapters { val ISLAND_TYPE = SimpleStringTypeAdapter.forEnum<IslandType>() val RARITY = SimpleStringTypeAdapter.forEnum<LorenzRarity>() - inline fun <reified T> GsonBuilder.registerTypeAdapter( + val LOCALE_DATE = object : TypeAdapter<LocalDate>() { + override fun write(out: JsonWriter, value: LocalDate) { + out.value(value.toString()) + } + + override fun read(reader: JsonReader): LocalDate { + return LocalDate.parse(reader.nextString()) + } + } + + inline + + fun <reified T> GsonBuilder.registerTypeAdapter( crossinline write: (JsonWriter, T) -> Unit, crossinline read: (JsonReader) -> T, ): GsonBuilder { |