mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2025-12-31 04:46:31 +00:00
Fixed packet bug for some users
This commit is contained in:
@@ -7,12 +7,18 @@ import net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket
|
||||
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket
|
||||
|
||||
class ActionBarCompatibility : ActionBarCompatibilityProxy {
|
||||
private val ClientboundSystemChatPacket.isActionBar: Boolean
|
||||
get() = this::class.java.declaredFields
|
||||
.first { it.type == Boolean::class.java }
|
||||
.apply { isAccessible = true }
|
||||
.get(this) as Boolean
|
||||
|
||||
override fun onSend(event: PacketEvent) {
|
||||
val player = event.player
|
||||
|
||||
when (val packet = event.packet.handle) {
|
||||
is ClientboundSetActionBarTextPacket -> player.pausePersistentActionBar()
|
||||
is ClientboundSystemChatPacket -> if (packet.c()) player.pausePersistentActionBar()
|
||||
is ClientboundSystemChatPacket -> if (packet.isActionBar) player.pausePersistentActionBar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,18 @@ import com.willfp.ecoskills.actionbar.pausePersistentActionBar
|
||||
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket
|
||||
|
||||
class ActionBarCompatibility : ActionBarCompatibilityProxy {
|
||||
private val ClientboundSystemChatPacket.isActionBar: Boolean
|
||||
get() = this::class.java.declaredFields
|
||||
.first { it.type == Boolean::class.java }
|
||||
.apply { isAccessible = true }
|
||||
.get(this) as Boolean
|
||||
|
||||
override fun onSend(event: PacketEvent) {
|
||||
val player = event.player
|
||||
|
||||
when (val packet = event.packet.handle) {
|
||||
is ClientboundSetActionBarTextPacket -> player.pausePersistentActionBar()
|
||||
is ClientboundSystemChatPacket -> if (packet.c()) player.pausePersistentActionBar()
|
||||
is ClientboundSystemChatPacket -> if (packet.isActionBar) player.pausePersistentActionBar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,18 @@ import com.willfp.ecoskills.actionbar.pausePersistentActionBar
|
||||
import net.minecraft.network.protocol.game.ClientboundSystemChatPacket
|
||||
|
||||
class ActionBarCompatibility : ActionBarCompatibilityProxy {
|
||||
private val ClientboundSystemChatPacket.isActionBar: Boolean
|
||||
get() = this::class.java.declaredFields
|
||||
.first { it.type == Boolean::class.java }
|
||||
.apply { isAccessible = true }
|
||||
.get(this) as Boolean
|
||||
|
||||
override fun onSend(event: PacketEvent) {
|
||||
val player = event.player
|
||||
|
||||
when (val packet = event.packet.handle) {
|
||||
is ClientboundSetActionBarTextPacket -> player.pausePersistentActionBar()
|
||||
is ClientboundSystemChatPacket -> if (packet.c()) player.pausePersistentActionBar()
|
||||
is ClientboundSystemChatPacket -> if (packet.isActionBar) player.pausePersistentActionBar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user