@@ -45,7 +45,7 @@ class UTextComponent : IChatComponent {
45
45
lateinit var component: IChatComponent
46
46
// #endif
47
47
private set
48
- var text: String
48
+ var text: String = " "
49
49
set(value) {
50
50
field = value
51
51
reInstance()
@@ -156,10 +156,12 @@ class UTextComponent : IChatComponent {
156
156
}
157
157
158
158
private fun reInstanceClick () {
159
+ val clickAction = clickAction
160
+ val clickValue = clickValue
159
161
if (clickAction == null || clickValue == null )
160
162
return
161
163
162
- val event = ClickEvent (clickAction, clickValue!! .formatIf(formatted))
164
+ val event = ClickEvent (clickAction, clickValue.formatIf(formatted))
163
165
164
166
// #if MC>=11600
165
167
// $$ component.style = component.style.setClickEvent(event)
@@ -171,17 +173,20 @@ class UTextComponent : IChatComponent {
171
173
}
172
174
173
175
private fun reInstanceHover () {
176
+ val hoverAction = hoverAction
177
+ val hoverValue = hoverValue
174
178
if (hoverAction == null || hoverValue == null )
175
179
return
176
180
177
181
// #if MC>=11602
178
- // $$ val event = HoverEvent<Any>(hoverAction as HoverEvent.Action<Any>, hoverValue!!)
182
+ // $$ @Suppress("UNCHECKED_CAST")
183
+ // $$ val event = HoverEvent(hoverAction as HoverEvent.Action<Any>, hoverValue)
179
184
// $$ setHoverEventHelper(event)
180
185
// #else
181
186
val value: IChatComponent = when (hoverValue) {
182
- is String -> ChatComponentText (hoverValue as String )
183
- is UTextComponent -> ( hoverValue as UTextComponent ) .component
184
- is IChatComponent -> hoverValue as IChatComponent
187
+ is String -> ChatComponentText (hoverValue)
188
+ is UTextComponent -> hoverValue.component
189
+ is IChatComponent -> hoverValue
185
190
else -> ChatComponentText (hoverValue.toString())
186
191
}
187
192
setHoverEventHelper(HoverEvent (
0 commit comments