Class AdventurePacketConvertor

java.lang.Object
net.minestom.server.adventure.AdventurePacketConvertor

public class AdventurePacketConvertor extends Object
Utility methods to convert adventure enums to their packet values.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull ServerPacket
    createSoundPacket(@NotNull net.kyori.adventure.sound.Sound sound, double x, double y, double z)
    Creates a sound packet from a sound and a location.
    Random variation by default unless a seed is provided in the Sound.
    static @NotNull ServerPacket
    createSoundPacket(@NotNull net.kyori.adventure.sound.Sound sound, @NotNull net.kyori.adventure.sound.Sound.Emitter emitter)
    Creates a sound effect packet from a sound and an emitter.
    Random variation by default unless a seed is provided in the Sound.
    createSoundStopPacket(@NotNull net.kyori.adventure.sound.SoundStop stop)
    Creates a sound stop packet from a sound stop.
    static <T> @NotNull ServerPacket
    createTitlePartPacket(@NotNull net.kyori.adventure.title.TitlePart<T> part, T value)
    Creates one of the three title packets from a title part and a value.
    static int
    getBossBarColorValue(net.kyori.adventure.bossbar.BossBar.Color color)
    Gets the int value of a boss bar color.
    static byte
    getBossBarFlagValue(@NotNull Collection<net.kyori.adventure.bossbar.BossBar.Flag> flags)
    Gets the byte value of a collection of boss bar flags.
    static int
    getBossBarOverlayValue(net.kyori.adventure.bossbar.BossBar.Overlay overlay)
    Gets the int value of a boss bar overlay.
    static int
    getNamedTextColorValue(@NotNull net.kyori.adventure.text.format.NamedTextColor color)
    Gets the int value from a named text color.
    static int
    getSoundSourceValue(net.kyori.adventure.sound.Sound.Source source)
    Gets the int value of a sound source.

    Methods inherited from class java.lang.Object

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

    • getBossBarOverlayValue

      public static int getBossBarOverlayValue(@NotNull net.kyori.adventure.bossbar.BossBar.Overlay overlay)
      Gets the int value of a boss bar overlay.
      Parameters:
      overlay - the overlay
      Returns:
      the value
    • getBossBarFlagValue

      public static byte getBossBarFlagValue(@NotNull @NotNull Collection<net.kyori.adventure.bossbar.BossBar.Flag> flags)
      Gets the byte value of a collection of boss bar flags.
      Parameters:
      flags - the flags
      Returns:
      the value
    • getBossBarColorValue

      public static int getBossBarColorValue(@NotNull net.kyori.adventure.bossbar.BossBar.Color color)
      Gets the int value of a boss bar color.
      Parameters:
      color - the color
      Returns:
      the value
    • getSoundSourceValue

      public static int getSoundSourceValue(@NotNull net.kyori.adventure.sound.Sound.Source source)
      Gets the int value of a sound source.
      Parameters:
      source - the source
      Returns:
      the value
    • getNamedTextColorValue

      public static int getNamedTextColorValue(@NotNull @NotNull net.kyori.adventure.text.format.NamedTextColor color)
      Gets the int value from a named text color.
      Parameters:
      color - the color
      Returns:
      the int value
    • createSoundPacket

      @NotNull public static @NotNull ServerPacket createSoundPacket(@NotNull @NotNull net.kyori.adventure.sound.Sound sound, double x, double y, double z)
      Creates a sound packet from a sound and a location.
      Random variation by default unless a seed is provided in the Sound.
      Parameters:
      sound - the sound
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      Returns:
      the sound packet
    • createSoundPacket

      @NotNull public static @NotNull ServerPacket createSoundPacket(@NotNull @NotNull net.kyori.adventure.sound.Sound sound, @NotNull net.kyori.adventure.sound.Sound.Emitter emitter)
      Creates a sound effect packet from a sound and an emitter.
      Random variation by default unless a seed is provided in the Sound.
      Parameters:
      sound - the sound
      emitter - the emitter, must be an Entity
      Returns:
      the sound packet
    • createSoundStopPacket

      public static ServerPacket createSoundStopPacket(@NotNull @NotNull net.kyori.adventure.sound.SoundStop stop)
      Creates a sound stop packet from a sound stop.
      Parameters:
      stop - the sound stop
      Returns:
      the sound stop packet
    • createTitlePartPacket

      @NotNull public static <T> @NotNull ServerPacket createTitlePartPacket(@NotNull @NotNull net.kyori.adventure.title.TitlePart<T> part, @NotNull T value)
      Creates one of the three title packets from a title part and a value.
      Type Parameters:
      T - the type of the part
      Parameters:
      part - the part
      value - the value
      Returns:
      the title packet