Class ViaDialogTagBuilder

java.lang.Object
io.github.projectunified.unidialog.viaversion.ViaDialogTagBuilder

public final class ViaDialogTagBuilder extends Object
Utility for building the CompoundTag of a dialog packet.
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.viaversion.nbt.tag.Tag
    component(com.viaversion.viaversion.libs.mcstructs.text.TextComponent component, com.viaversion.viaversion.util.SerializerVersion base, com.viaversion.viaversion.util.SerializerVersion target)
    Map the component from the base serializer to the target serializer and serialize it to a tag
    static com.viaversion.nbt.tag.Tag
    componentTag(com.viaversion.viaversion.libs.mcstructs.text.TextComponent component)
    Serialize a text component to a canonical component tag, normalized to the target version on serialization
    static com.viaversion.viaversion.libs.mcstructs.text.TextComponent
    Deserialize a legacy formatted string (e.g.
    static com.viaversion.nbt.tag.CompoundTag
    item(com.viaversion.viaversion.api.minecraft.item.Item item, com.viaversion.viaversion.util.SerializerVersion serializer)
    Serialize a Item to the item tag used by the dialog item body
    static com.viaversion.nbt.tag.CompoundTag
    loreEntry(com.viaversion.viaversion.libs.mcstructs.text.TextComponent component, com.viaversion.viaversion.util.SerializerVersion serializer)
    Wrap a text component as a lore line, mirroring ViaVersion's updateComponentList
    static void
    putComponent(com.viaversion.nbt.tag.CompoundTag target, String key, @Nullable com.viaversion.viaversion.libs.mcstructs.text.TextComponent component, com.viaversion.viaversion.util.SerializerVersion base, com.viaversion.viaversion.util.SerializerVersion to)
    Write a text component tag into target under key if component is not null
    static com.viaversion.viaversion.util.SerializerVersion
    serializerFor(com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
    Return the SerializerVersion for the given protocol version

    Methods inherited from class java.lang.Object

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

    • deserializeLegacy

      public static com.viaversion.viaversion.libs.mcstructs.text.TextComponent deserializeLegacy(String input)
      Deserialize a legacy formatted string (e.g. "§aHello") into a TextComponent
      Parameters:
      input - the legacy string
      Returns:
      the parsed component
    • componentTag

      public static com.viaversion.nbt.tag.Tag componentTag(com.viaversion.viaversion.libs.mcstructs.text.TextComponent component)
      Serialize a text component to a canonical component tag, normalized to the target version on serialization
      Parameters:
      component - the component to serialize
      Returns:
      the canonical component tag
    • component

      public static com.viaversion.nbt.tag.Tag component(com.viaversion.viaversion.libs.mcstructs.text.TextComponent component, com.viaversion.viaversion.util.SerializerVersion base, com.viaversion.viaversion.util.SerializerVersion target)
      Map the component from the base serializer to the target serializer and serialize it to a tag
      Parameters:
      component - the component to serialize
      base - the serializer of the version the component was created for
      target - the serializer of the version the component is sent to
      Returns:
      the text component tag
    • putComponent

      public static void putComponent(com.viaversion.nbt.tag.CompoundTag target, String key, @Nullable @Nullable com.viaversion.viaversion.libs.mcstructs.text.TextComponent component, com.viaversion.viaversion.util.SerializerVersion base, com.viaversion.viaversion.util.SerializerVersion to)
      Write a text component tag into target under key if component is not null
      Parameters:
      target - the tag to write into
      key - the key to write
      component - the component to write, may be null
      base - the serializer of the version the component was created for
      to - the serializer of the version the component is sent to
    • serializerFor

      public static com.viaversion.viaversion.util.SerializerVersion serializerFor(com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
      Return the SerializerVersion for the given protocol version
      Parameters:
      version - the protocol version
      Returns:
      the matching serializer
    • item

      public static com.viaversion.nbt.tag.CompoundTag item(com.viaversion.viaversion.api.minecraft.item.Item item, com.viaversion.viaversion.util.SerializerVersion serializer)
      Serialize a Item to the item tag used by the dialog item body
      Parameters:
      item - the item to serialize
      serializer - the serializer to serialize the item's components with
      Returns:
      the item tag
    • loreEntry

      public static com.viaversion.nbt.tag.CompoundTag loreEntry(com.viaversion.viaversion.libs.mcstructs.text.TextComponent component, com.viaversion.viaversion.util.SerializerVersion serializer)
      Wrap a text component as a lore line, mirroring ViaVersion's updateComponentList
      Parameters:
      component - the component to wrap
      serializer - the serializer to serialize the component with
      Returns:
      the lore entry