aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt37
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt2
3 files changed, 30 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
index 2da2fbda2..53ae224d9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
@@ -49,7 +49,7 @@ object CollectionUtils {
// Taken and modified from Skytils
@JvmStatic
- fun <T> T.equalsOneOf(vararg other: T): Boolean {
+ fun <T> T?.equalsOneOf(vararg other: T): Boolean {
for (obj in other) {
if (this == obj) return true
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
index e577ba28f..16fe8cd6e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
@@ -1,6 +1,5 @@
package at.hannibal2.skyhanni.utils
-import at.hannibal2.skyhanni.test.command.ErrorManager
import net.minecraft.item.EnumDyeColor
import java.awt.Color
@@ -40,11 +39,33 @@ enum class LorenzColor(val chatColorCode: Char, private val color: Color, privat
fun toConfigColour(): String = "0:255:${color.red}:${color.green}:${color.blue}"
+ fun toDyeColor(): EnumDyeColor = when (this) {
+ WHITE -> EnumDyeColor.WHITE
+ GOLD -> EnumDyeColor.ORANGE
+ AQUA -> EnumDyeColor.MAGENTA
+ BLUE -> EnumDyeColor.LIGHT_BLUE
+ YELLOW -> EnumDyeColor.YELLOW
+ GREEN -> EnumDyeColor.LIME
+ LIGHT_PURPLE -> EnumDyeColor.PINK
+ DARK_GRAY -> EnumDyeColor.GRAY
+ GRAY -> EnumDyeColor.SILVER
+ DARK_AQUA -> EnumDyeColor.CYAN
+ DARK_PURPLE -> EnumDyeColor.PURPLE
+ DARK_BLUE -> EnumDyeColor.BLUE
+// GOLD -> EnumDyeColor.BROWN
+ DARK_GREEN -> EnumDyeColor.GREEN
+ DARK_RED -> EnumDyeColor.RED
+ BLACK -> EnumDyeColor.BLACK
+ RED -> EnumDyeColor.RED
+
+ CHROMA -> EnumDyeColor.WHITE
+ }
+
companion object {
fun EnumDyeColor.toLorenzColor() = when (this) {
EnumDyeColor.WHITE -> WHITE
- EnumDyeColor.MAGENTA -> LIGHT_PURPLE
+ EnumDyeColor.MAGENTA -> AQUA
EnumDyeColor.PINK -> LIGHT_PURPLE
EnumDyeColor.RED -> RED
EnumDyeColor.SILVER -> GRAY
@@ -54,13 +75,11 @@ enum class LorenzColor(val chatColorCode: Char, private val color: Color, privat
EnumDyeColor.BLUE -> BLUE
EnumDyeColor.PURPLE -> DARK_PURPLE
EnumDyeColor.YELLOW -> YELLOW
- else -> {
- ErrorManager.logErrorWithData(
- Exception("Unknown dye color: $this"),
- "Unknown dye color: $this"
- )
- null
- }
+ EnumDyeColor.ORANGE -> GOLD
+ EnumDyeColor.LIGHT_BLUE -> BLUE
+ EnumDyeColor.CYAN -> DARK_AQUA
+ EnumDyeColor.BROWN -> GOLD
+ EnumDyeColor.BLACK -> BLACK
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
index e64c55213..39dac5247 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt
@@ -8,7 +8,7 @@ class TimeLimitedSet<T>(expireAfterWrite: Duration) {
fun add(element: T) = cache.put(element, Unit)
- fun contains(element: T): Boolean = cache.containsKey(element)
+ operator fun contains(element: T): Boolean = cache.containsKey(element)
fun clear() = cache.clear()