mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Use a map for bone and prayer lookups
This commit is contained in:
@@ -10,7 +10,7 @@ val PLAYER_PRAYERS: SetMultimap<Player, Prayer> = MultimapBuilder.hashKeys()
|
|||||||
.enumSetValues(Prayer::class.java)
|
.enumSetValues(Prayer::class.java)
|
||||||
.build<Player, Prayer>()
|
.build<Player, Prayer>()
|
||||||
|
|
||||||
val Player.currentPrayers : Set<Prayer>
|
val Player.currentPrayers: Set<Prayer>
|
||||||
get() = PLAYER_PRAYERS[this]
|
get() = PLAYER_PRAYERS[this]
|
||||||
|
|
||||||
enum class Bone(val id: Int, val xp: Double) {
|
enum class Bone(val id: Int, val xp: Double) {
|
||||||
@@ -35,9 +35,9 @@ enum class Bone(val id: Int, val xp: Double) {
|
|||||||
OURG_BONES(id = 4834, xp = 140.0);
|
OURG_BONES(id = 4834, xp = 140.0);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val BONES = Bone.values()
|
private val BONES = Bone.values().associateBy { it.id }
|
||||||
|
|
||||||
operator fun get(id: Int) = BONES.find { bone -> bone.id == id }
|
operator fun get(id: Int) = BONES[id]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,9 +62,9 @@ enum class Prayer(val button: Int, val level: Int, val setting: Int, val drain:
|
|||||||
SMITE(button = 685, level = 52, setting = 100, drain = 0.2);
|
SMITE(button = 685, level = 52, setting = 100, drain = 0.2);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val PRAYERS = Prayer.values()
|
private val PRAYERS = Prayer.values().associateBy { it.button }
|
||||||
|
|
||||||
fun forButton(button: Int) = PRAYERS.find { it.button == button }
|
fun forButton(button: Int) = PRAYERS[button]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user