From 6a0266e88f203eac60d3c9a6704e16853265a80b Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 13 Jun 2021 12:22:40 +0100 Subject: [PATCH] Add methods for looking up entries in an enum Signed-off-by: Graham --- .../kotlin/org/openrs2/cache/config/enum/EnumType.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cache-550/src/main/kotlin/org/openrs2/cache/config/enum/EnumType.kt b/cache-550/src/main/kotlin/org/openrs2/cache/config/enum/EnumType.kt index 49b441ee..d6c4c882 100644 --- a/cache-550/src/main/kotlin/org/openrs2/cache/config/enum/EnumType.kt +++ b/cache-550/src/main/kotlin/org/openrs2/cache/config/enum/EnumType.kt @@ -97,4 +97,14 @@ public class EnumType(id: Int) : ConfigType(id) { buf.writeByte(0) } + + public fun getString(key: Int): String { + val strings = strings ?: return defaultString + return strings.getOrDefault(key, defaultString) + } + + public fun getInt(key: Int): Int { + val ints = ints ?: return defaultInt + return ints.getOrDefault(key, defaultInt) + } }