Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: Storage Classes to Kotlin #3106

Open
wants to merge 4 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {

val logger = LorenzLogger("ConfigMigration")
const val CONFIG_VERSION = 69
const val CONFIG_VERSION = 70
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
Expand Down
163 changes: 0 additions & 163 deletions src/main/java/at/hannibal2/skyhanni/config/Features.java

This file was deleted.

149 changes: 149 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/config/Features.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package at.hannibal2.skyhanni.config

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.SkyHanniMod.Companion.version
import at.hannibal2.skyhanni.config.features.About
import at.hannibal2.skyhanni.config.features.chat.ChatConfig
import at.hannibal2.skyhanni.config.features.combat.CombatConfig
import at.hannibal2.skyhanni.config.features.crimsonisle.CrimsonIsleConfig
import at.hannibal2.skyhanni.config.features.dev.DevConfig
import at.hannibal2.skyhanni.config.features.dungeon.DungeonConfig
import at.hannibal2.skyhanni.config.features.event.EventConfig
import at.hannibal2.skyhanni.config.features.fishing.FishingConfig
import at.hannibal2.skyhanni.config.features.garden.GardenConfig
import at.hannibal2.skyhanni.config.features.gui.GUIConfig
import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig
import at.hannibal2.skyhanni.config.features.mining.MiningConfig
import at.hannibal2.skyhanni.config.features.misc.MiscConfig
import at.hannibal2.skyhanni.config.features.rift.RiftConfig
import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressConfig
import at.hannibal2.skyhanni.config.features.slayer.SlayerConfig
import at.hannibal2.skyhanni.config.storage.Storage
import at.hannibal2.skyhanni.utils.LorenzUtils.isAprilFoolsDay
import com.google.gson.annotations.Expose
import io.github.notenoughupdates.moulconfig.Config
import io.github.notenoughupdates.moulconfig.Social
import io.github.notenoughupdates.moulconfig.annotations.Category
import io.github.notenoughupdates.moulconfig.gui.HorizontalAlign
import io.github.notenoughupdates.moulconfig.processor.ProcessedCategory
import net.minecraft.util.ResourceLocation

class Features : Config() {
private val discord: ResourceLocation = ResourceLocation("notenoughupdates:social/discord.png")
private val github: ResourceLocation = ResourceLocation("notenoughupdates:social/github.png")
private val patreon: ResourceLocation = ResourceLocation("notenoughupdates:social/patreon.png")

override fun shouldAutoFocusSearchbar(): Boolean {
return true
}

override fun alignCategory(category: ProcessedCategory, isSelected: Boolean): HorizontalAlign {
if (isAprilFoolsDay) return HorizontalAlign.RIGHT
return super.alignCategory(category, isSelected)
}

override fun getSocials(): List<Social> {
return listOf(
Social.forLink("Discord", discord, "https://discord.com/invite/skyhanni-997079228510117908"),
Social.forLink("GitHub", github, "https://github.com/hannibal002/SkyHanni"),
Social.forLink("Patreon", patreon, "https://www.patreon.com/hannibal2")
)
}

override fun saveNow() {
SkyHanniMod.configManager.saveConfig(ConfigFileType.FEATURES, "close-gui")
}

override fun getTitle(): String {
// Minecraft does not render RTL strings very nicely, so we reverse the string here. Not authentic, but close enough.
val modName = if (isAprilFoolsDay) StringBuilder().append("اسکای هانی").reverse().toString()
else "SkyHanni"

return "$modName $version by §channibal2§r, config by §5Moulberry §rand §5nea89"
}


/*
* If you are adding a new category, please insert it alphabetically
* The only exceptions to this are About and GUI, which are pinned to the top
* and Misc and Dev, which are to be at the bottom. Thanks!
*/
// Top
@Expose
@Category(name = "About", desc = "Information about SkyHanni and updates.")
var about: About = About()

@JvmField
@Expose
@Category(name = "GUI", desc = "Change the locations of GUI elements (§e/sh gui§7).")
var gui: GUIConfig = GUIConfig()

// Islands
@Expose
@Category(name = "Garden", desc = "Features for the Garden island.")
var garden: GardenConfig = GardenConfig()

@Expose
@Category(name = "Crimson Isle", desc = "Things to do on the Crimson Isle/Nether island.")
var crimsonIsle: CrimsonIsleConfig = CrimsonIsleConfig()

@Expose
@Category(name = "The Rift", desc = "Features for The Rift dimension.")
var rift: RiftConfig = RiftConfig()

// Skills
@Expose
@Category(name = "Fishing", desc = "Fishing stuff.")
var fishing: FishingConfig = FishingConfig()

@Expose
@Category(name = "Mining", desc = "Features that help you break blocks.")
var mining: MiningConfig = MiningConfig()

// Combat like
@Expose
@Category(name = "Combat", desc = "Everything combat and PvE related.")
var combat: CombatConfig = CombatConfig()

@Expose
@Category(name = "Slayer", desc = "Slayer features.")
var slayer: SlayerConfig = SlayerConfig()

@Expose
@Category(name = "Dungeon", desc = "Features that change the Dungeons experience in The Catacombs.")
var dungeon: DungeonConfig = DungeonConfig()

// Misc
@Expose
@Category(name = "Inventory", desc = "Change the behavior of items and the inventory.")
var inventory: InventoryConfig = InventoryConfig()

@Expose
@Category(name = "Events", desc = "Stuff that is not always available.")
var event: EventConfig = EventConfig()

@Expose
@Category(name = "Skill Progress", desc = "Skill Progress related config options.")
var skillProgress: SkillProgressConfig = SkillProgressConfig()

@Expose
@Category(name = "Chat", desc = "Change how the chat looks.")
var chat: ChatConfig = ChatConfig()

@JvmField
@Expose
@Category(name = "Misc", desc = "Settings without a category.")
var misc: MiscConfig = MiscConfig()

// Bottom
@Expose
@Category(name = "Dev", desc = "Debug and test stuff. Developers are cool.")
var dev: DevConfig = DevConfig()

@Expose
var storage: Storage = Storage()

@Expose
@Suppress("unused")
var lastVersion: Int = ConfigUpdaterMigrator.CONFIG_VERSION
}
26 changes: 0 additions & 26 deletions src/main/java/at/hannibal2/skyhanni/config/SackData.java

This file was deleted.

21 changes: 21 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/config/SackData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package at.hannibal2.skyhanni.config

import at.hannibal2.skyhanni.data.SackItem
import at.hannibal2.skyhanni.utils.NEUInternalName
import com.google.gson.annotations.Expose
import java.util.*

class SackData {
@Expose
var players: MutableMap<UUID, PlayerSpecific> = HashMap()

class PlayerSpecific {
@Expose
var profiles: MutableMap<String, ProfileSpecific> = HashMap()
}

class ProfileSpecific {
@Expose
var sackContents: Map<NEUInternalName, SackItem> = HashMap()
}
}
Loading
Loading