diff options
| author | Linnea Gräf <nea@nea.moe> | 2024-05-05 15:36:05 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2024-05-05 16:00:31 +0200 |
| commit | a4914380e66944cab5fe4126caaf082d84bdf042 (patch) | |
| tree | b7fcc49b22128453032fbdd3475c243b8fe6fb48 /src/main | |
| parent | 8eec1cc284ed3ab4c982a54d678128b8feb16d64 (diff) | |
| download | SkyHanni-ifxrarecrash.tar.gz SkyHanni-ifxrarecrash.tar.bz2 SkyHanni-ifxrarecrash.zip | |
Fix rare chat crashifxrarecrash
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PlayerAllChatEvent.kt | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PlayerAllChatEvent.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PlayerAllChatEvent.kt index bb2de0010..7d6d1a7ac 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PlayerAllChatEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PlayerAllChatEvent.kt @@ -1,7 +1,10 @@ package at.hannibal2.skyhanni.data.hypixel.chat.event import at.hannibal2.skyhanni.utils.ComponentSpan +import net.minecraft.util.ChatComponentText import net.minecraft.util.IChatComponent +import net.minecraftforge.fml.common.eventhandler.ListenerList +import org.jetbrains.annotations.ApiStatus class PlayerAllChatEvent( val levelComponent: ComponentSpan?, @@ -16,4 +19,39 @@ class PlayerAllChatEvent( val levelColor = levelComponent?.sampleStyleAtStart()?.color val level by lazy { levelComponent?.getText()?.toInt() } val isAGuest by lazy { privateIslandGuest != null } + + companion object { + private val listenerList = ListenerList(AbstractChatEvent( + ComponentSpan.empty(), + ComponentSpan.empty(), + ChatComponentText(""), + "").listenerList) + } + + /** + * This method is here to prevent FML from trying to add its own constructor. FML adds a public no args + * constructor to every Event class, which is used to determine the listener list using inheritance. This is done + * using class transformations, more specifically ASM. Sadly this class contains expressions which cause the class + * writer used by ASM to perform type unifications. Due to the way ASM is loaded these type unifications do not + * have access to some of the classes used in this class, causing a ClassNotFoundException. In order to prevent + * these unifications from happening we need to prevent FML from trying to generate this constructor, which we do + * by having our own setup function. + */ + override fun setup() { + super.setup() + } + + /** + * This method is required if [setup] is present. + */ + @ApiStatus.Internal + constructor() : this(null, null, null, "", + ComponentSpan.empty(), ComponentSpan.empty(), ChatComponentText("")) + + /** + * This method is required if [setup] is present. + */ + override fun getListenerList(): ListenerList { + return PlayerAllChatEvent.listenerList + } } |
