blob: 0b6178399fb8507d27afb0ae6e96b24c90cb5e89 (
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 at.hannibal2.skyhanni.events
import at.hannibal2.skyhanni.test.command.CopyErrorCommand
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.eventhandler.Event
abstract class LorenzEvent : Event() {
private val eventName by lazy {
this::class.simpleName
}
fun postAndCatch(): Boolean {
return runCatching {
MinecraftForge.EVENT_BUS.post(this)
}.onFailure {
if (it is NoSuchMethodError) {
LorenzUtils.chat("§c[SkyHanni] You need to use a newer version of NotEnoughUpdates (alpha-11 or newer)! If you need help downloading it, go to the skyhanni discord.")
} else {
CopyErrorCommand.logError(it, "Caught an ${it::class.simpleName ?: "error"} at ${eventName}: '${it.message}'")
}
}.getOrDefault(isCanceled)
}
}
|