summaryrefslogtreecommitdiff
path: root/src/main/kotlin/de/romjaki/pluggabledino/api/Events.kt
blob: 6f43844e261e05661fd66cba622ebf60243d905e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package de.romjaki.pluggabledino.api

import java.util.*

object Events {
    fun broadcastEvent(event: Event) {
        for (plugin in PluginLoader.plugins.values) {
            Arrays.stream(plugin.javaClass.methods!!)
                    .filter { it.getAnnotation(EventHandler::class.java) != null }
                    .filter { it.parameterCount == 1 }
                    .filter { it.parameterTypes[0].isInstance(event) }
                    .forEach { it.invoke(plugin, event) }
        }
    }
}