From c52a71ee63c633d17d7a935c0aa92ddda904c750 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 22 Jun 2024 09:20:18 +0200 Subject: do not use Supplier --- .../skyhanni/features/gui/customscoreboard/ScoreboardElements.kt | 5 ++--- .../skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt | 6 ++---- .../java/at/hannibal2/skyhanni/test/hotswap/HotswapSupport.kt | 8 ++------ src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt | 3 +-- src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt | 5 ++--- 5 files changed, 9 insertions(+), 18 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt index 6249ac295..116cecd19 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt @@ -46,7 +46,6 @@ import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.TimeLimitedSet import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.TimeUtils.formatted -import java.util.function.Supplier import kotlin.time.Duration.Companion.seconds internal var confirmedUnknownLines = listOf() @@ -75,7 +74,7 @@ private fun onRemoval(line: String) { internal var amountOfUnknownLines = 0 enum class ScoreboardElement( - private val displayPair: Supplier>, + private val displayPair: () -> List, val showWhen: () -> Boolean, private val configLine: String, ) { @@ -285,7 +284,7 @@ enum class ScoreboardElement( private fun getPair(): List { return try { - displayPair.get() + displayPair() } catch (e: NoSuchElementException) { listOf("" to HorizontalAlignment.LEFT) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt index d8fdf532b..ebeed5eee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.eventsConfig -import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardEvents.NEW_YEAR import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardEvents.VOTING import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern import at.hannibal2.skyhanni.features.misc.ServerRestartTitle @@ -19,7 +18,6 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.removeResets import at.hannibal2.skyhanni.utils.TabListData -import java.util.function.Supplier import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern as SbPattern /** @@ -35,7 +33,7 @@ private fun getSbLines(): List { } enum class ScoreboardEvents( - private val displayLine: Supplier>, + private val displayLine: () -> List, private val showWhen: () -> Boolean, private val configLine: String, ) { @@ -193,7 +191,7 @@ enum class ScoreboardEvents( override fun toString() = configLine - fun getLines(): List = displayLine.get() + fun getLines(): List = displayLine() companion object { fun getEvent() = buildList { diff --git a/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupport.kt b/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupport.kt index 447a6f5aa..94894507c 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupport.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupport.kt @@ -1,16 +1,12 @@ package at.hannibal2.skyhanni.test.hotswap -import java.util.function.Supplier - object HotswapSupport { private val isForgeSidePresent = runCatching { Class.forName("moe.nea.hotswapagentforge.forge.HotswapEvent") }.isSuccess private val obj = if (isForgeSidePresent) { - Supplier { HotswapSupportImpl() } - } else { - Supplier { null } - }.get() + HotswapSupportImpl() + } else null fun isLoaded(): Boolean { return obj?.isLoaded() ?: false diff --git a/src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt b/src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt index 8bbe5bba3..c110d6d6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt @@ -9,7 +9,6 @@ import net.minecraft.client.shader.ShaderLinkHelper import org.apache.commons.lang3.StringUtils import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.OpenGLException -import java.util.function.Supplier /** * Superclass for shader objects to compile and attach vertex and fragment shaders to the shader program @@ -106,7 +105,7 @@ abstract class Shader(val vertex: String, val fragment: String) { * to the uniform in the shader file. * @param uniformValuesSupplier The supplier that changes / sets the uniform's value */ - fun registerUniform(uniformType: Uniform.UniformType, name: String, uniformValuesSupplier: Supplier) { + fun registerUniform(uniformType: Uniform.UniformType, name: String, uniformValuesSupplier: () -> T) { uniforms.add(Uniform(this, uniformType, name, uniformValuesSupplier)) } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt b/src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt index e3adf2b4d..139b2082c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.utils.shader import java.util.Objects -import java.util.function.Supplier /** * Class to handle shader uniform types @@ -14,7 +13,7 @@ class Uniform( shader: Shader, private val uniformType: UniformType, val name: String, - private val uniformValuesSupplier: Supplier, + private val uniformValuesSupplier: () -> T, ) { class UniformType { @@ -32,7 +31,7 @@ class Uniform( private var previousUniformValue: T? = null fun update() { - val newUniformValue: T = uniformValuesSupplier.get() + val newUniformValue: T = uniformValuesSupplier() if (!Objects.deepEquals(previousUniformValue, newUniformValue)) { when (uniformType) { UniformType.FLOAT -> { -- cgit