Skip to content

Commit

Permalink
Add migration for old patcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jun 20, 2024
1 parent 4a7079c commit 8cefda2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package club.sk1er.patcher.config;

public class OldPatcherConfig {
public static boolean showOwnNametag;
public static boolean shadowedNametagText;
public static boolean disableNametagBoxes;
}
32 changes: 32 additions & 0 deletions src/main/kotlin/org/polyfrost/polynametag/config/ModConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import cc.polyfrost.oneconfig.config.data.Mod
import cc.polyfrost.oneconfig.config.data.ModType
import cc.polyfrost.oneconfig.config.elements.BasicOption
import cc.polyfrost.oneconfig.config.elements.OptionPage
import cc.polyfrost.oneconfig.utils.Notifications
import club.sk1er.patcher.config.OldPatcherConfig
import club.sk1er.patcher.config.PatcherConfig
import org.polyfrost.polynametag.PolyNametag
import org.polyfrost.polynametag.render.NametagPreview
Expand Down Expand Up @@ -64,6 +66,8 @@ object ModConfig : Config(Mod("Nametags", ModType.UTIL_QOL, "/polynametag.svg"),
@Transient
val nametagPreview = NametagPreview(category = "General")

var hasMigratedPatcher = false

init {
initialize()
addDependency("backgroundColor", "background")
Expand All @@ -75,6 +79,34 @@ object ModConfig : Config(Mod("Nametags", ModType.UTIL_QOL, "/polynametag.svg"),
}
addDependency("cornerRadius", "rounded")
hideIf("essentialOffset") { !PolyNametag.isEssential }

if (PolyNametag.isPatcher && !hasMigratedPatcher) {
try {
Class.forName("club.sk1er.patcher.config.OldPatcherConfig")
var didAnything = false
if (OldPatcherConfig.shadowedNametagText) {
textType = 1
didAnything = true
}
if (OldPatcherConfig.disableNametagBoxes) {
background = false
didAnything = true
}
if (OldPatcherConfig.showOwnNametag) {
showOwnNametag = true
didAnything = true
}

hasMigratedPatcher = true
save()

if (didAnything) {
Notifications.INSTANCE.send("PolyNametag", "Migrated Patcher settings replaced by PolyNametag. Please check PolyNametag's settings to make sure they are correct.")
}
} catch (_: ClassNotFoundException) {

}
}
}

override fun getCustomOption(
Expand Down

0 comments on commit 8cefda2

Please sign in to comment.