blob: 3496441fe0896412e967209e31d7238b1370370c (
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
26
27
28
29
30
|
package at.hannibal2.skyhanni.mixins.hooks
import at.hannibal2.skyhanni.events.TabListLineRenderEvent
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
import kotlin.reflect.KProperty
var tabListGuard by object : ThreadLocal<Boolean>() {
override fun initialValue(): Boolean {
return false
}
}
operator fun <T> ThreadLocal<T>.setValue(t: Any?, property: KProperty<*>, any: T) {
this.set(any)
}
operator fun <T> ThreadLocal<T>.getValue(t: Any?, property: KProperty<*>): T {
return get()
}
fun getPlayerName(original: String, cir: CallbackInfoReturnable<String>) {
if (tabListGuard) return
val event = TabListLineRenderEvent(original)
event.postAndCatch()
val newText = event.text
if (original != newText) {
cir.returnValue = newText
}
}
|