Add sendNow methods

This commit is contained in:
DBotThePony 2023-07-30 10:17:26 +07:00
parent 85ca7d8a24
commit c4e7b8ff15
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -58,6 +58,12 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) {
}
}
fun sendNow(ply: Player, packet: Any) {
if (ply is ServerPlayer) {
channel.send(PacketDistributor.PLAYER.with { ply }, packet)
}
}
fun sendTracking(entity: Entity, packet: Any) {
if ((NULLABLE_MINECRAFT_SERVER?.playerCount ?: 0) <= 0) {
return
@ -78,6 +84,10 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) {
queue.add(Task(channel, distributor, packet))
}
fun sendNow(distributor: PacketDistributor.PacketTarget, packet: Any) {
channel.send(distributor, packet)
}
private var nextNetworkPacketID = 0
fun <T> add(