Skip to content

Commit df18ae1

Browse files
committed
add reified version
1 parent ba460c3 commit df18ae1

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/entity/EntityStorage.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ object EntityStorage : Listener {
109109
}
110110
}
111111

112+
/**
113+
* Schedules a task to run when the entity with id [uuid] is loaded, or runs the task immediately
114+
* if the entity is already loaded
115+
*/
116+
@JvmStatic
117+
inline fun <reified T: PylonEntity<*>> whenEntityLoads(uuid: UUID, crossinline consumer: (T) -> Unit)
118+
= whenEntityLoads(uuid, T::class.java) { t -> consumer(t) }
119+
112120
@JvmStatic
113121
fun isPylonEntity(uuid: UUID): Boolean
114122
= get(uuid) != null

0 commit comments

Comments
 (0)