Class GlowBufUtils

java.lang.Object
net.glowstone.net.GlowBufUtils

public final class GlowBufUtils extends Object
Contains several utility methods for writing special data types to @{link ByteBuf}s.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.util.BlockVector
    readBlockPosition​(io.netty.buffer.ByteBuf buf)
    Read an encoded block vector (position) from the buffer.
    readChat​(io.netty.buffer.ByteBuf buf)
    Read an encoded chat message from the buffer.
    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)
     
    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
    writeUuid​(io.netty.buffer.ByteBuf buf, UUID uuid)
    Write a UUID encoded as two longs to the buffer.
    static void
    writeValue​(io.netty.buffer.ByteBuf buf, Object value, MetadataType type)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • readMetadata

      public static List<MetadataMap.Entry> readMetadata(io.netty.buffer.ByteBuf buf) throws IOException
      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

      public static CompoundTag readCompound(io.netty.buffer.ByteBuf buf)
      Read an uncompressed compound NBT tag from the buffer.
      Parameters:
      buf - The buffer.
      Returns:
      The tag read, or null.
    • writeCompound

      public static void writeCompound(io.netty.buffer.ByteBuf buf, CompoundTag data)
      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

      public static UUID readUuid(io.netty.buffer.ByteBuf buf)
      Read a UUID encoded as two longs from the buffer.
      Parameters:
      buf - The buffer.
      Returns:
      The UUID read.
    • writeUuid

      public static void writeUuid(io.netty.buffer.ByteBuf buf, UUID uuid)
      Write a UUID encoded as two longs to the buffer.
      Parameters:
      buf - The buffer.
      uuid - The UUID to write.
    • readChat

      public static TextMessage readChat(io.netty.buffer.ByteBuf buf) throws IOException
      Read an encoded chat message from the buffer.
      Parameters:
      buf - The buffer.
      Returns:
      The chat message read.
      Throws:
      IOException - on read failure.
    • writeChat

      public static void writeChat(io.netty.buffer.ByteBuf buf, TextMessage text) throws IOException
      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 buffer
      particle - The Particle to write.
      Throws:
      IOException - on write failure.