From 65a4842de7a306d45bdda99788a7925443932b39 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 27 Jun 2023 23:08:19 +0200 Subject: Code cleanup --- .../at/hannibal2/skyhanni/utils/LorenzColor.kt | 40 ++++++++++------------ 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt index 4199dd6d3..6fdfaa2af 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt @@ -1,9 +1,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.test.command.CopyErrorCommand -import net.minecraft.client.Minecraft import net.minecraft.item.EnumDyeColor -import net.minecraft.util.ChatComponentText import java.awt.Color enum class LorenzColor(private var chatColorCode: Char, private val color: Color) { @@ -38,26 +36,24 @@ enum class LorenzColor(private var chatColorCode: Char, private val color: Color } companion object { - fun getMatchingColor(enumDyeColor: EnumDyeColor): LorenzColor? { - return when(enumDyeColor) { - EnumDyeColor.WHITE -> WHITE - EnumDyeColor.MAGENTA -> LIGHT_PURPLE - EnumDyeColor.PINK -> LIGHT_PURPLE - EnumDyeColor.RED -> RED - EnumDyeColor.SILVER -> GRAY - EnumDyeColor.GRAY -> GRAY - EnumDyeColor.GREEN -> DARK_GREEN - EnumDyeColor.LIME -> GREEN - EnumDyeColor.BLUE -> BLUE - EnumDyeColor.PURPLE -> DARK_PURPLE - EnumDyeColor.YELLOW -> YELLOW - else -> { - CopyErrorCommand.logError( - Exception("Unknown dye color: $enumDyeColor"), - "Unknown dye color: $enumDyeColor" - ) - return null - } + fun EnumDyeColor.toLorenzColor() = when (this) { + EnumDyeColor.WHITE -> WHITE + EnumDyeColor.MAGENTA -> LIGHT_PURPLE + EnumDyeColor.PINK -> LIGHT_PURPLE + EnumDyeColor.RED -> RED + EnumDyeColor.SILVER -> GRAY + EnumDyeColor.GRAY -> GRAY + EnumDyeColor.GREEN -> DARK_GREEN + EnumDyeColor.LIME -> GREEN + EnumDyeColor.BLUE -> BLUE + EnumDyeColor.PURPLE -> DARK_PURPLE + EnumDyeColor.YELLOW -> YELLOW + else -> { + CopyErrorCommand.logError( + Exception("Unknown dye color: $this"), + "Unknown dye color: $this" + ) + null } } } -- cgit