Class ViaDialog<T extends ViaDialog<T>>

java.lang.Object
io.github.projectunified.unidialog.viaversion.dialog.ViaDialog<T>
Type Parameters:
T - the type of the dialog itself, for method chaining
All Implemented Interfaces:
Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T>
Direct Known Subclasses:
ViaConfirmationDialog, ViaDialogListDialog, ViaMultiActionDialog, ViaNoticeDialog, ViaServerLinksDialog

public abstract class ViaDialog<T extends ViaDialog<T>> extends Object implements Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T>
A ViaVersion-based implementation of Dialog for building dialogs.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.github.projectunified.unidialog.core.dialog.Dialog

    Dialog.AfterAction
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ViaDialog(String defaultNamespace, Function<String,com.viaversion.viaversion.libs.mcstructs.text.TextComponent> componentDeserializer)
    Constructor for ViaDialog
  • Method Summary

    Modifier and Type
    Method
    Description
    Set the action to be performed after an action is taken in the dialog
    Set the body of the dialog
    canCloseWithEscape(boolean canCloseWithEscape)
    Set the option to allow the dialog to be closed with the escape key
    protected com.viaversion.viaversion.libs.mcstructs.text.TextComponent
    Deserialize a string to a TextComponent
    externalTitle(@Nullable com.viaversion.viaversion.libs.mcstructs.text.TextComponent externalTitle)
    Set the external title of the dialog, used for displaying the dialog in a multi-dialog dialog
    externalTitle(@Nullable String externalTitle)
    Set the external title of the dialog, which is used for displaying the dialog in a multi-dialog dialog
    Create a dialog action builder configured by the given consumer
    final com.viaversion.nbt.tag.CompoundTag
    getDialogTag(com.viaversion.viaversion.api.protocol.version.ProtocolVersion baseVersion, com.viaversion.viaversion.api.protocol.version.ProtocolVersion targetVersion)
    Build the dialog CompoundTag for the given base and target protocol versions
    final com.viaversion.nbt.tag.CompoundTag
    getDialogTag(com.viaversion.viaversion.util.SerializerVersion baseVersion, com.viaversion.viaversion.util.SerializerVersion targetVersion)
    Build the dialog CompoundTag for the given base and target serializers
    Set the input for the dialog
    Create an opener for the dialog
    pause(boolean pause)
    Set the option to pause the game while the dialog is open
    title(com.viaversion.viaversion.libs.mcstructs.text.TextComponent title)
    Set the title of the dialog
    title(String title)
    Set the title of the dialog
    protected abstract void
    writeDialogType(com.viaversion.nbt.tag.CompoundTag tag, com.viaversion.viaversion.util.SerializerVersion baseVersion, com.viaversion.viaversion.util.SerializerVersion targetVersion)
    Write the type-specific fields of this dialog, including the type key

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.github.projectunified.unidialog.core.dialog.Dialog

    body, input
  • Constructor Details

    • ViaDialog

      protected ViaDialog(String defaultNamespace, Function<String,com.viaversion.viaversion.libs.mcstructs.text.TextComponent> componentDeserializer)
      Constructor for ViaDialog
      Parameters:
      defaultNamespace - the default namespace for custom actions
      componentDeserializer - the function to deserialize components from strings
  • Method Details

    • deserialize

      protected com.viaversion.viaversion.libs.mcstructs.text.TextComponent deserialize(String input)
      Deserialize a string to a TextComponent
      Parameters:
      input - the string to deserialize
      Returns:
      the deserialized component
    • title

      public T title(com.viaversion.viaversion.libs.mcstructs.text.TextComponent title)
      Set the title of the dialog
      Parameters:
      title - the title
      Returns:
      the dialog itself for method chaining
    • title

      public T title(String title)
      Description copied from interface: Dialog
      Set the title of the dialog
      Specified by:
      title in interface Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T extends ViaDialog<T>>
      Parameters:
      title - the title of the dialog
      Returns:
      the dialog itself for method chaining
    • externalTitle

      public T externalTitle(@Nullable @Nullable com.viaversion.viaversion.libs.mcstructs.text.TextComponent externalTitle)
      Set the external title of the dialog, used for displaying the dialog in a multi-dialog dialog
      Parameters:
      externalTitle - the external title
      Returns:
      the dialog itself for method chaining
    • externalTitle

      public T externalTitle(@Nullable @Nullable String externalTitle)
      Description copied from interface: Dialog
      Set the external title of the dialog, which is used for displaying the dialog in a multi-dialog dialog
      Specified by:
      externalTitle in interface Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T extends ViaDialog<T>>
      Parameters:
      externalTitle - the external title of the dialog
      Returns:
      the dialog itself for method chaining
    • canCloseWithEscape

      public T canCloseWithEscape(boolean canCloseWithEscape)
      Description copied from interface: Dialog
      Set the option to allow the dialog to be closed with the escape key
      Specified by:
      canCloseWithEscape in interface Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T extends ViaDialog<T>>
      Parameters:
      canCloseWithEscape - whether the dialog can be closed with the escape key
      Returns:
      the dialog itself for method chaining
    • pause

      public T pause(boolean pause)
      Description copied from interface: Dialog
      Set the option to pause the game while the dialog is open
      Specified by:
      pause in interface Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T extends ViaDialog<T>>
      Parameters:
      pause - whether the dialog should pause the game
      Returns:
      the dialog itself for method chaining
    • afterAction

      public T afterAction(Dialog.AfterAction afterAction)
      Description copied from interface: Dialog
      Set the action to be performed after an action is taken in the dialog
      Specified by:
      afterAction in interface Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T extends ViaDialog<T>>
      Parameters:
      afterAction - the action to be performed after an action is taken
      Returns:
      the dialog itself for method chaining
    • body

      public T body(Consumer<ViaDialogBodyBuilder> bodyBuilder)
      Description copied from interface: Dialog
      Set the body of the dialog
      Specified by:
      body in interface Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T extends ViaDialog<T>>
      Parameters:
      bodyBuilder - the body builder for the dialog
      Returns:
      the dialog itself for method chaining
    • input

      public T input(String key, Consumer<ViaDialogInputBuilder> inputBuilder)
      Description copied from interface: Dialog
      Set the input for the dialog
      Specified by:
      input in interface Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T extends ViaDialog<T>>
      Parameters:
      key - the key for the input
      inputBuilder - the input builder for the dialog
      Returns:
      the dialog itself for method chaining
    • getActionBuilder

      protected ViaDialogActionBuilder getActionBuilder(Consumer<ViaDialogActionBuilder> action)
      Create a dialog action builder configured by the given consumer
      Parameters:
      action - the action builder consumer
      Returns:
      the configured action builder
    • writeDialogType

      protected abstract void writeDialogType(com.viaversion.nbt.tag.CompoundTag tag, com.viaversion.viaversion.util.SerializerVersion baseVersion, com.viaversion.viaversion.util.SerializerVersion targetVersion)
      Write the type-specific fields of this dialog, including the type key
      Parameters:
      tag - the tag to write into
      baseVersion - the serializer of the server version the dialog is created for
      targetVersion - the serializer of the version the dialog is sent to
    • getDialogTag

      public final com.viaversion.nbt.tag.CompoundTag getDialogTag(com.viaversion.viaversion.api.protocol.version.ProtocolVersion baseVersion, com.viaversion.viaversion.api.protocol.version.ProtocolVersion targetVersion)
      Build the dialog CompoundTag for the given base and target protocol versions
      Parameters:
      baseVersion - the protocol version of the server the dialog is created for
      targetVersion - the protocol version of the player the dialog is sent to
      Returns:
      the dialog tag
    • getDialogTag

      public final com.viaversion.nbt.tag.CompoundTag getDialogTag(com.viaversion.viaversion.util.SerializerVersion baseVersion, com.viaversion.viaversion.util.SerializerVersion targetVersion)
      Build the dialog CompoundTag for the given base and target serializers
      Parameters:
      baseVersion - the serializer of the server version the dialog is created for
      targetVersion - the serializer of the version the dialog is sent to
      Returns:
      the dialog tag
    • opener

      public ViaDialogOpener opener()
      Description copied from interface: Dialog
      Create an opener for the dialog
      Specified by:
      opener in interface Dialog<ViaItem,ViaDialogBodyBuilder,ViaDialogInputBuilder,T extends ViaDialog<T>>
      Returns:
      the dialog opener