summaryrefslogtreewikicommitdiff
path: root/bukkit/src/packet
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2026-03-26 23:15:33 -0400
committerFreya Murphy <freya@freyacat.org>2026-03-27 23:09:23 -0400
commitf8322cd21cde68a72b05efbad3a05b8e67c0bdd0 (patch)
treed7e60bc8fedadc8fa7ae725571cad1f398eaf6dc /bukkit/src/packet
downloadkenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.tar.gz
kenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.tar.bz2
kenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.zip
initial
Diffstat (limited to 'bukkit/src/packet')
-rw-r--r--bukkit/src/packet/BlockChangePacket.kt20
-rw-r--r--bukkit/src/packet/EntityDestroyPacket.kt13
-rw-r--r--bukkit/src/packet/EntityMetadataPacket.kt17
-rw-r--r--bukkit/src/packet/EntityTeleportPacket.kt19
4 files changed, 69 insertions, 0 deletions
diff --git a/bukkit/src/packet/BlockChangePacket.kt b/bukkit/src/packet/BlockChangePacket.kt
new file mode 100644
index 0000000..7d11f4e
--- /dev/null
+++ b/bukkit/src/packet/BlockChangePacket.kt
@@ -0,0 +1,20 @@
+package cat.freya.khs.bukkit.packet
+
+import com.github.retrooper.packetevents.PacketEvents
+import com.github.retrooper.packetevents.util.Vector3i
+import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerBlockChange
+import io.github.retrooper.packetevents.util.SpigotConversionUtil
+import org.bukkit.Bukkit
+import org.bukkit.Location
+import org.bukkit.Material
+import org.bukkit.entity.Player as BukkitPlayer
+
+data class BlockChangePacket(val location: Location, val material: Material) {
+ fun send(player: BukkitPlayer) {
+ val blockData = Bukkit.createBlockData(material)
+ val state = SpigotConversionUtil.fromBukkitBlockData(blockData)
+ val vector = Vector3i(location.blockX, location.blockY, location.blockZ)
+ val packet = WrapperPlayServerBlockChange(vector, state)
+ PacketEvents.getAPI().playerManager.sendPacket(player, packet)
+ }
+}
diff --git a/bukkit/src/packet/EntityDestroyPacket.kt b/bukkit/src/packet/EntityDestroyPacket.kt
new file mode 100644
index 0000000..3240b81
--- /dev/null
+++ b/bukkit/src/packet/EntityDestroyPacket.kt
@@ -0,0 +1,13 @@
+package cat.freya.khs.bukkit.packet
+
+import com.github.retrooper.packetevents.PacketEvents
+import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDestroyEntities
+import org.bukkit.entity.Entity
+import org.bukkit.entity.Player as BukkitPlayer
+
+data class EntityDestroyPacket(val entiy: Entity) {
+ fun send(player: BukkitPlayer) {
+ val packet = WrapperPlayServerDestroyEntities(entiy.entityId)
+ PacketEvents.getAPI().playerManager.sendPacket(player, packet)
+ }
+}
diff --git a/bukkit/src/packet/EntityMetadataPacket.kt b/bukkit/src/packet/EntityMetadataPacket.kt
new file mode 100644
index 0000000..6d5978a
--- /dev/null
+++ b/bukkit/src/packet/EntityMetadataPacket.kt
@@ -0,0 +1,17 @@
+package cat.freya.khs.bukkit.packet
+
+import com.github.retrooper.packetevents.PacketEvents
+import com.github.retrooper.packetevents.protocol.entity.data.EntityData
+import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes
+import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata
+import org.bukkit.entity.Entity
+import org.bukkit.entity.Player as BukkitPlayer
+
+data class EntityMetadataPacket(val entiy: Entity, val glow: Boolean) {
+ fun send(player: BukkitPlayer) {
+ val glowingByte = if (glow) 0x40 else 0x0
+ val data = EntityData(0x0, EntityDataTypes.BYTE, glowingByte.toByte())
+ val packet = WrapperPlayServerEntityMetadata(entiy.entityId, listOf(data))
+ PacketEvents.getAPI().playerManager.sendPacket(player, packet)
+ }
+}
diff --git a/bukkit/src/packet/EntityTeleportPacket.kt b/bukkit/src/packet/EntityTeleportPacket.kt
new file mode 100644
index 0000000..7e3beb1
--- /dev/null
+++ b/bukkit/src/packet/EntityTeleportPacket.kt
@@ -0,0 +1,19 @@
+package cat.freya.khs.bukkit.packet
+
+import com.github.retrooper.packetevents.PacketEvents
+import com.github.retrooper.packetevents.util.Vector3d
+import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityTeleport
+import org.bukkit.Location
+import org.bukkit.entity.Entity
+import org.bukkit.entity.Player as BukkitPlayer
+
+data class EntityTeleportPacket(val entity: Entity, val position: Location) {
+ fun send(player: BukkitPlayer) {
+ val vector = Vector3d(position.x, position.y, position.z)
+ val yaw = 0f
+ val pitch = 0f
+ val onGround = false
+ val packet = WrapperPlayServerEntityTeleport(entity.entityId, vector, yaw, pitch, onGround)
+ PacketEvents.getAPI().playerManager.sendPacket(player, packet)
+ }
+}