Class ViaDialogTagBuilder
java.lang.Object
io.github.projectunified.unidialog.viaversion.ViaDialogTagBuilder
Utility for building the
CompoundTag of a dialog packet.-
Method Summary
Modifier and TypeMethodDescriptionstatic com.viaversion.nbt.tag.Tagcomponent(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 tagstatic com.viaversion.nbt.tag.TagcomponentTag(com.viaversion.viaversion.libs.mcstructs.text.TextComponent component) Serialize a text component to a canonical component tag, normalized to the target version on serializationstatic com.viaversion.viaversion.libs.mcstructs.text.TextComponentdeserializeLegacy(String input) Deserialize a legacy formatted string (e.g.static com.viaversion.nbt.tag.CompoundTagitem(com.viaversion.viaversion.api.minecraft.item.Item item, com.viaversion.viaversion.util.SerializerVersion serializer) Serialize aItemto the item tag used by the dialog item bodystatic com.viaversion.nbt.tag.CompoundTagloreEntry(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 updateComponentListstatic voidputComponent(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 intotargetunderkeyifcomponentis not nullstatic com.viaversion.viaversion.util.SerializerVersionserializerFor(com.viaversion.viaversion.api.protocol.version.ProtocolVersion version) Return theSerializerVersionfor the given protocol version
-
Method Details
-
deserializeLegacy
public static com.viaversion.viaversion.libs.mcstructs.text.TextComponent deserializeLegacy(String input) Deserialize a legacy formatted string (e.g."§aHello") into aTextComponent- 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 serializebase- the serializer of the version the component was created fortarget- 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 intotargetunderkeyifcomponentis not null- Parameters:
target- the tag to write intokey- the key to writecomponent- the component to write, may be nullbase- the serializer of the version the component was created forto- 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 theSerializerVersionfor 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 aItemto the item tag used by the dialog item body- Parameters:
item- the item to serializeserializer- 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 wrapserializer- the serializer to serialize the component with- Returns:
- the lore entry
-