Platform: PacketAdapter - Dani-error/velar GitHub Wiki
PlatformPacketAdapter
is a generic, cross-platform interface designed for building outgoing entity- and player-related packets on different server implementations like Bukkit, allowing Velar to send protocol-level data in a platform-agnostic way.
Method | Description |
---|---|
createEntitySpawnPacket() |
Create packet to spawn entity. |
createEntityRemovePacket() |
Create packet to remove entity. |
createPlayerInfoPacket(action) |
Modify tablist visibility or skin info. |
createRotationPacket(yaw, pitch) |
Force player/entity rotation. |
createAnimationPacket(animation) |
Trigger entity animation. |
createEquipmentPacket(slot, item) |
Equip item in a specific slot. |
createCustomPayloadPacket(channelId, payload) |
Send plugin message packet. |
createEntityMetaPacket(metadata, value) |
Update entity metadata. |
createTeamsPacket(mode, teamName, info, players) |
Modify scoreboard teams. |
initialize(platform) |
Called to initialize the adapter with a Platform context. |
Use:
val adapter = BukkitProtocolAdapter.packetAdapter()
It auto-selects:
- ✅ ProtocolLib – if installed
- 🛠️ PacketEvents – fallback
You can also select explicitly:
val libAdapter = BukkitProtocolAdapter.protocolLib()
val pktEventsAdapter = BukkitProtocolAdapter.packetEvents()
Each implements PlatformPacketAdapter<World, Player, ItemStack, Plugin>
.
You can define your own adapter to support other platforms or protocols:
class CustomPacketAdapter : PlatformPacketAdapter<MyWorld, MyPlayer, MyItem, MyPlugin> {
override fun createEntitySpawnPacket(): OutboundPacket<...> {
// your custom logic
}
// implement all other methods...
override fun initialize(platform: Platform<MyWorld, MyPlayer, MyItem, MyPlugin>) {
// optional init logic
}
}