blob: d474d6501bc8b0b0fce5053b0499397e6c31f89a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package moe.nea.firmament.features
import moe.nea.firmament.events.FirmamentEvent
import moe.nea.firmament.events.subscription.Subscription
import moe.nea.firmament.events.subscription.SubscriptionList
import moe.nea.firmament.util.ErrorUtil
import moe.nea.firmament.util.compatloader.ICompatMeta
object FeatureManager {
fun subscribeEvents() {
SubscriptionList.allLists.forEach { list ->
if (ICompatMeta.shouldLoad(list.javaClass.name))
ErrorUtil.catch("Error while loading events from $list") {
list.provideSubscriptions {
subscribeSingleEvent(it)
}
}
}
}
private fun <T : FirmamentEvent> subscribeSingleEvent(it: Subscription<T>) {
it.eventBus.subscribe(false, "${it.owner.javaClass.simpleName}:${it.methodName}", it.invoke)
}
}
|