diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-21 16:12:57 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-21 16:12:57 +0200 |
commit | c9eb62dedbec7a5a9f626ba778b14c951fac383e (patch) | |
tree | 0c3df4d8d9242e14dd77e3c7b4ae6858b1a9c530 /src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt | |
parent | 68c6bd4834cca0fe224074209ac90f04454e4850 (diff) | |
download | skyhanni-c9eb62dedbec7a5a9f626ba778b14c951fac383e.tar.gz skyhanni-c9eb62dedbec7a5a9f626ba778b14c951fac383e.tar.bz2 skyhanni-c9eb62dedbec7a5a9f626ba778b14c951fac383e.zip |
more makeAccessible usage
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt index d498d5e99..0e1c5e5e4 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.test.command.CopyErrorCommand import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.makeAccessible import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.OSUtils import com.google.gson.JsonElement @@ -178,8 +179,7 @@ object SkyHanniConfigSearchResetCommand { val line = term.split(".").drop(1) var field: Field? = null for (entry in line) { - field = obj.javaClass.getField(entry) - field.isAccessible = true + field = obj.javaClass.getField(entry).makeAccessible() parentObject = obj obj = field.get(obj) } @@ -201,8 +201,7 @@ object SkyHanniConfigSearchResetCommand { val name = field.name val fieldName = "$parentName.$name" - field.isAccessible = true - val newObj = field.get(obj) + val newObj = field.makeAccessible().get(obj) map[fieldName] = newObj if (newObj != null) { if (newObj !is Boolean && newObj !is String && newObj !is Long && newObj !is Int && newObj !is Double) { @@ -243,8 +242,6 @@ object SkyHanniConfigSearchResetCommand { } } - private fun Field.makeAccessible() = also { isAccessible = true } - private fun Any.getObjectName(): String { if (this is Position) { val x = javaClass.getDeclaredField("x").makeAccessible().get(this) |