Skip to content

Commit

Permalink
Fix an issue with config loading & compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
spartacus04 committed Jan 17, 2024
1 parent ab97ab1 commit 296bad0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
9 changes: 6 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ tasks {
exclude("ScopeJVMKt.class")
exclude("DebugProbesKt.bin")

minimize()

minimize{
exclude(dependency("xyz.xenondevs.invui:.*:.*"))
}
}
}

Expand All @@ -105,9 +108,9 @@ tasks.register<ProGuardTask>("proguardJar") {

injars(tasks.shadowJar.flatMap { it.archiveFile })

outjars("build/libs/${rootProject.name}_${project.version}.jar")

configuration("proguard-rules.pro")

outjars("build/libs/${rootProject.name}_${project.version}.jar")
}

tasks.processResources {
Expand Down
3 changes: 2 additions & 1 deletion proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keepclassmembers,allowobfuscation class * {
-keepclassmembers class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-keepattributes *Annotation*,EventHandler
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
1 change: 1 addition & 0 deletions src/main/java/me/spartacus04/jext/config/ConfigFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ object ConfigFactory {
if(PLUGIN.dataFolder.resolve("config.json").exists()) {
updateOldConfig()
}

return FileBind.create(Config::class.java)
}
}
2 changes: 0 additions & 2 deletions src/main/java/me/spartacus04/jext/gui/GuiBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,5 @@ class GuiBuilder {
.addIngredient('#', border)
.setContent(listOf(inventory))
}


}
}
8 changes: 7 additions & 1 deletion src/main/java/me/spartacus04/jext/utils/FileBind.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ open class FileBind(@Transient private val filePath: String, @Transient private
}
}

gson.fromJson(file.readText(), typeToken)
val obj = gson.fromJson(file.readText(), typeToken)

obj.javaClass.declaredFields.forEach { field ->
field.isAccessible = true

field.set(this, field.get(obj))
}
}

fun save() {
Expand Down

0 comments on commit 296bad0

Please sign in to comment.