aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/RewardWarningConfig.java71
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt31
4 files changed, 48 insertions, 75 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
index 6f5fe68ed..0f638e22b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
@@ -9,7 +9,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {
val logger = LorenzLogger("ConfigMigration")
- const val CONFIG_VERSION = 11
+ const val CONFIG_VERSION = 12
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/RewardWarningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/RewardWarningConfig.java
index bd3f158ff..0213e7cd1 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/RewardWarningConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/RewardWarningConfig.java
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.config.features.garden.visitor;
import at.hannibal2.skyhanni.config.FeatureToggle;
-import at.hannibal2.skyhanni.config.HasLegacyId;
+import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward;
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList;
@@ -13,13 +13,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static at.hannibal2.skyhanni.config.features.garden.visitor.RewardWarningConfig.ItemWarnEntry.CULTIVATING_I;
-import static at.hannibal2.skyhanni.config.features.garden.visitor.RewardWarningConfig.ItemWarnEntry.DEDICATION_IV;
-import static at.hannibal2.skyhanni.config.features.garden.visitor.RewardWarningConfig.ItemWarnEntry.GREEN_BANDANA;
-import static at.hannibal2.skyhanni.config.features.garden.visitor.RewardWarningConfig.ItemWarnEntry.MUSIC_RUNE;
-import static at.hannibal2.skyhanni.config.features.garden.visitor.RewardWarningConfig.ItemWarnEntry.OVERGROWN_GRASS;
-import static at.hannibal2.skyhanni.config.features.garden.visitor.RewardWarningConfig.ItemWarnEntry.SPACE_HELMET;
-
public class RewardWarningConfig {
@Expose
@@ -54,59 +47,15 @@ public class RewardWarningConfig {
name = "Items",
desc = "Warn for these reward items."
)
- @ConfigEditorDraggableList(
- exampleText = {
- "§9Flowering Bouquet",
- "§9Overgrown Grass",
- "§9Green Bandana",
- "§9Dedication IV",
- "§9Music Rune",
- "§cSpace Helmet",
- "§9Cultivating I",
- "§9Replenish I",
- }
- )
- public List<ItemWarnEntry> drops = new ArrayList<>(Arrays.asList(
- OVERGROWN_GRASS,
- GREEN_BANDANA,
- DEDICATION_IV,
- MUSIC_RUNE,
- SPACE_HELMET,
- CULTIVATING_I
+ @ConfigEditorDraggableList
+ public List<VisitorReward> drops = new ArrayList<>(Arrays.asList(
+ VisitorReward.OVERGROWN_GRASS,
+ VisitorReward.GREEN_BANDANA,
+ VisitorReward.DEDICATION,
+ VisitorReward.MUSIC_RUNE,
+ VisitorReward.SPACE_HELMET,
+ VisitorReward.CULTIVATING,
+ VisitorReward.REPLENISH
));
- public enum ItemWarnEntry implements HasLegacyId {
- FLOWERING_BOUQUET("§9Flowering Bouquet", 0),
- OVERGROWN_GRASS("§9Overgrown Grass", 1),
- GREEN_BANDANA("§9Green Bandana", 2),
- DEDICATION_IV("§9Dedication IV", 3),
- MUSIC_RUNE("§9Music Rune", 4),
- SPACE_HELMET("§cSpace Helmet", 5),
- CULTIVATING_I("§9Cultivating I", 6),
- REPLENISH_I("§9Replenish I", 7),
- ;
-
- private final String str;
- private final int legacyId;
-
- ItemWarnEntry(String str, int legacyId) {
- this.str = str;
- this.legacyId = legacyId;
- }
-
- // Constructor if new enum elements are added post-migration
- ItemWarnEntry(String str) {
- this(str, -1);
- }
-
- @Override
- public int getLegacyId() {
- return legacyId;
- }
-
- @Override
- public String toString() {
- return str;
- }
- }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index a1e795e72..22a53c388 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.features.garden.visitor
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
-import at.hannibal2.skyhanni.config.features.garden.visitor.RewardWarningConfig.ItemWarnEntry
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
@@ -48,6 +47,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.getLorenzVec
import at.hannibal2.skyhanni.utils.renderables.Renderable
+import com.google.gson.JsonArray
+import com.google.gson.JsonPrimitive
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiEditSign
import net.minecraft.entity.EntityLivingBase
@@ -607,7 +608,21 @@ class GardenVisitorFeatures {
event.move(3, "garden.visitorHypixelArrivedMessage", "garden.visitors.hypixelArrivedMessage")
event.move(3, "garden.visitorHideChat", "garden.visitors.hideChat")
event.move(11, "garden.visitors.rewardWarning.drops", "garden.visitors.rewardWarning.drops") { element ->
- ConfigUtils.migrateIntArrayListToEnumArrayList(element, ItemWarnEntry::class.java)
+ ConfigUtils.migrateIntArrayListToEnumArrayList(element, VisitorReward::class.java)
+ }
+ event.move(12, "garden.visitors.rewardWarning.drops", "garden.visitors.rewardWarning.drops") { element ->
+ val drops = JsonArray()
+ for (jsonElement in element.asJsonArray) {
+ val old = jsonElement.asString
+ val new = VisitorReward.entries.firstOrNull { old.startsWith(it.name) }
+ if (new == null) {
+ println("error with migrating old VisitorReward entity: '$old'")
+ continue
+ }
+ drops.add(JsonPrimitive(new.name))
+ }
+
+ drops
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt
index d6aabd3b5..cdaee688d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt
@@ -1,26 +1,35 @@
package at.hannibal2.skyhanni.features.garden.visitor
-import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment
+import at.hannibal2.skyhanni.config.HasLegacyId
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
-enum class VisitorReward(private val rawInternalName: String) {
- FLOWERING_BOUQUET("FLOWERING_BOUQUET"),
- OVERGROWN_GRASS("OVERGROWN_GRASS"),
- GREEN_BANDANA("GREEN_BANDANA"),
- DEDICATION("DEDICATION;4"),
- MUSIC_RUNE("MUSIC_RUNE;1"),
- SPACE_HELMET("DCTR_SPACE_HELM"),
- CULTIVATING("CULTIVATING;1"),
- REPLENISH("REPLENISH;1"),
+enum class VisitorReward(private val rawInternalName: String, val displayName: String, private val legacyId: Int = -1) : HasLegacyId {
+ FLOWERING_BOUQUET("FLOWERING_BOUQUET", "§9Flowering Bouquet", legacyId = 0),
+ OVERGROWN_GRASS("OVERGROWN_GRASS", "§9Overgrown Grass", legacyId = 1),
+ GREEN_BANDANA("GREEN_BANDANA", "§9Green Bandana", legacyId = 2),
+ DEDICATION("DEDICATION;4", "§9Dedication IV", legacyId = 3),
+ MUSIC_RUNE("MUSIC_RUNE;1", "§9Music Rune", legacyId = 4),
+ SPACE_HELMET("DCTR_SPACE_HELM", "§cSpace Helmet", legacyId = 5),
+ CULTIVATING("CULTIVATING;1", "§9Cultivating I", legacyId = 6),
+ REPLENISH("REPLENISH;1", "§9Replenish I", legacyId = 7),
;
private val internalName by lazy { rawInternalName.asInternalName() }
val itemStack by lazy { internalName.getItemStack() }
- val displayName by lazy { itemStack.nameWithEnchantment ?: internalName.asString() }
+ // TODO use this instead of hard coded item names once moulconfig no longer calls toString before the neu repo gets loaded
+// val displayName by lazy { itemStack.nameWithEnchantment ?: internalName.asString() }
companion object {
fun getByInternalName(internalName: NEUInternalName) = entries.firstOrNull { it.internalName == internalName }
}
+
+ override fun getLegacyId(): Int {
+ return legacyId
+ }
+
+ override fun toString(): String {
+ return displayName
+ }
}