From 21a36637230a6ed79bbc1723a88cc34fc9aa8205 Mon Sep 17 00:00:00 2001 From: alexcrea <42614139+alexcrea@users.noreply.github.com> Date: Mon, 17 Mar 2025 14:39:14 +0100 Subject: [PATCH] fix stupid init bug --- .../xyz/alexcrea/cuanvil/util/AnvilUseType.kt | 11 ++------ .../alexcrea/cuanvil/util/AnvilUseTypeUtil.kt | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilUseTypeUtil.kt diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilUseType.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilUseType.kt index d765fa3..00f272f 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilUseType.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilUseType.kt @@ -1,6 +1,5 @@ package xyz.alexcrea.cuanvil.util -import io.delilaheve.util.ConfigOptions import org.bukkit.Material import xyz.alexcrea.cuanvil.config.WorkPenaltyType.WorkPenaltyPart @@ -52,20 +51,14 @@ enum class AnvilUseType( ), ; - companion object { - private fun defaultPath(typeName: String): String { - return "${ConfigOptions.WORK_PENALTY_ROOT}.$typeName" - } - - } - constructor( typeName: String, defaultPenalty: WorkPenaltyPart, displayName: String, displayMat: Material ) : this( - typeName, defaultPath(typeName), + typeName, + AnvilUseTypeUtil.defaultPath(typeName), // stupid util class defaultPenalty, displayName, displayMat ) diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilUseTypeUtil.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilUseTypeUtil.kt new file mode 100644 index 0000000..c72a35a --- /dev/null +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/util/AnvilUseTypeUtil.kt @@ -0,0 +1,26 @@ +package xyz.alexcrea.cuanvil.util + +import io.delilaheve.util.ConfigOptions + +object AnvilUseTypeUtil { + + /* + By stupidity of kotlin not allowing static function outside of companion object I need to do another util class only for 1 function: + Companion object on enum class seems to get initialized AFTER the enum itself + that mean. if you want to call a static function on the enum class itself YOU CAN'T. you need to do this stupid thing + or you can make a stupid top level function OR object that even worse because of global scope pollution + (btw was gpt ""solution"". fortunately I do not "vibe code" so I do what I know instead of stupid AI solution & code) + I mean, this is still global scope pollution bc of a USELESS class that SHOULD not exist but as a class is better than a random *ss function + + sorry for the rent but this made me frustrated + + Note: I still like a lot of part of kotlin compared to java but this part is one that I hate + */ + /** + * Get config path for normal anvil use + */ + fun defaultPath(typeName: String): String { + return "${ConfigOptions.WORK_PENALTY_ROOT}.$typeName" + } + +} \ No newline at end of file