Package net.glowstone.net
Class GlowBufUtils
java.lang.Object
net.glowstone.net.GlowBufUtils
Contains several utility methods for writing special data types to @{link ByteBuf}s.
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.util.BlockVector
readBlockPosition
(io.netty.buffer.ByteBuf buf) Read an encoded block vector (position) from the buffer.static TextMessage
readChat
(io.netty.buffer.ByteBuf buf) Read an encoded chat message from the buffer.static CompoundTag
readCompound
(io.netty.buffer.ByteBuf buf) Read an uncompressed compound NBT tag from the buffer.static org.bukkit.inventory.EquipmentSlot
readHand
(io.netty.buffer.ByteBuf buf) static List<MetadataMap.Entry>
readMetadata
(io.netty.buffer.ByteBuf buf) Read a list of mob metadata entries from the buffer.static org.bukkit.inventory.ItemStack
readSlot
(io.netty.buffer.ByteBuf buf) Read an item stack from the buffer.static org.bukkit.inventory.ItemStack
readSlot
(io.netty.buffer.ByteBuf buf, boolean network) Read an item stack from the buffer.static UUID
readUuid
(io.netty.buffer.ByteBuf buf) Read a UUID encoded as two longs from the buffer.static void
writeBlockPosition
(io.netty.buffer.ByteBuf buf, long x, long y, long z) Write an encoded block vector (position) to the buffer.static void
writeBlockPosition
(io.netty.buffer.ByteBuf buf, org.bukkit.util.Vector vector) Write an encoded block vector (position) to the buffer.static void
writeChat
(io.netty.buffer.ByteBuf buf, TextMessage text) Write an encoded chat message to the buffer.static void
writeCompound
(io.netty.buffer.ByteBuf buf, CompoundTag data) Write an uncompressed compound NBT tag to the buffer.static void
writeHand
(io.netty.buffer.ByteBuf buf, org.bukkit.inventory.EquipmentSlot hand) static void
writeMetadata
(io.netty.buffer.ByteBuf buf, List<MetadataMap.Entry> entries) Write a list of mob metadata entries to the buffer.static void
writeParticle
(io.netty.buffer.ByteBuf buf, com.destroystokyo.paper.ParticleBuilder particle) Write a Particle to the buffer.static void
writeSlot
(io.netty.buffer.ByteBuf buf, org.bukkit.inventory.ItemStack stack) Write an item stack to the buffer.static void
Write a UUID encoded as two longs to the buffer.static void
writeValue
(io.netty.buffer.ByteBuf buf, Object value, MetadataType type)
-
Method Details
-
readMetadata
Read a list of mob metadata entries from the buffer.- Parameters:
buf
- The buffer.- Returns:
- The metadata.
- Throws:
IOException
- if the buffer could not be read
-
writeMetadata
public static void writeMetadata(io.netty.buffer.ByteBuf buf, List<MetadataMap.Entry> entries) throws IOException Write a list of mob metadata entries to the buffer.- Parameters:
buf
- The buffer.entries
- The metadata.- Throws:
IOException
- if the buffer could not be written to
-
writeValue
public static void writeValue(io.netty.buffer.ByteBuf buf, Object value, MetadataType type) throws IOException - Throws:
IOException
-
readCompound
Read an uncompressed compound NBT tag from the buffer.- Parameters:
buf
- The buffer.- Returns:
- The tag read, or null.
-
writeCompound
Write an uncompressed compound NBT tag to the buffer.- Parameters:
buf
- The buffer.data
- The tag to write, or null.
-
readSlot
public static org.bukkit.inventory.ItemStack readSlot(io.netty.buffer.ByteBuf buf) throws IOException Read an item stack from the buffer.- Parameters:
buf
- The buffer.- Returns:
- The stack read, or null.
- Throws:
IOException
-
readSlot
public static org.bukkit.inventory.ItemStack readSlot(io.netty.buffer.ByteBuf buf, boolean network) throws IOException Read an item stack from the buffer.- Parameters:
buf
- The buffer.network
- Mark network source.- Returns:
- The stack read, or null.
- Throws:
IOException
-
writeSlot
public static void writeSlot(io.netty.buffer.ByteBuf buf, org.bukkit.inventory.ItemStack stack) Write an item stack to the buffer.- Parameters:
buf
- The buffer.stack
- The stack to write, or null.
-
readBlockPosition
public static org.bukkit.util.BlockVector readBlockPosition(io.netty.buffer.ByteBuf buf) Read an encoded block vector (position) from the buffer.- Parameters:
buf
- The buffer.- Returns:
- The vector read.
-
writeBlockPosition
public static void writeBlockPosition(io.netty.buffer.ByteBuf buf, org.bukkit.util.Vector vector) Write an encoded block vector (position) to the buffer.- Parameters:
buf
- The buffer.vector
- The vector to write.
-
writeBlockPosition
public static void writeBlockPosition(io.netty.buffer.ByteBuf buf, long x, long y, long z) Write an encoded block vector (position) to the buffer.- Parameters:
buf
- The buffer.x
- The x value.y
- The y value.z
- The z value.
-
readUuid
Read a UUID encoded as two longs from the buffer.- Parameters:
buf
- The buffer.- Returns:
- The UUID read.
-
writeUuid
Write a UUID encoded as two longs to the buffer.- Parameters:
buf
- The buffer.uuid
- The UUID to write.
-
readChat
Read an encoded chat message from the buffer.- Parameters:
buf
- The buffer.- Returns:
- The chat message read.
- Throws:
IOException
- on read failure.
-
writeChat
Write an encoded chat message to the buffer.- Parameters:
buf
- The buffer.text
- The chat message to write.- Throws:
IOException
- on write failure.
-
readHand
public static org.bukkit.inventory.EquipmentSlot readHand(io.netty.buffer.ByteBuf buf) throws IOException - Throws:
IOException
-
writeHand
public static void writeHand(io.netty.buffer.ByteBuf buf, org.bukkit.inventory.EquipmentSlot hand) -
writeParticle
public static void writeParticle(io.netty.buffer.ByteBuf buf, com.destroystokyo.paper.ParticleBuilder particle) throws IOException Write a Particle to the buffer.- Parameters:
buf
- The bufferparticle
- The Particle to write.- Throws:
IOException
- on write failure.
-