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 -
Method Summary
Modifier and TypeMethodDescriptionafterAction(Dialog.AfterAction afterAction) Set the action to be performed after an action is taken in the dialogbody(Consumer<ViaDialogBodyBuilder> bodyBuilder) Set the body of the dialogcanCloseWithEscape(boolean canCloseWithEscape) Set the option to allow the dialog to be closed with the escape keyprotected com.viaversion.viaversion.libs.mcstructs.text.TextComponentdeserialize(String input) Deserialize a string to aTextComponentexternalTitle(@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 dialogexternalTitle(@Nullable String externalTitle) Set the external title of the dialog, which is used for displaying the dialog in a multi-dialog dialogprotected ViaDialogActionBuilderCreate a dialog action builder configured by the given consumerfinal com.viaversion.nbt.tag.CompoundTaggetDialogTag(com.viaversion.viaversion.api.protocol.version.ProtocolVersion baseVersion, com.viaversion.viaversion.api.protocol.version.ProtocolVersion targetVersion) Build the dialogCompoundTagfor the given base and target protocol versionsfinal com.viaversion.nbt.tag.CompoundTaggetDialogTag(com.viaversion.viaversion.util.SerializerVersion baseVersion, com.viaversion.viaversion.util.SerializerVersion targetVersion) Build the dialogCompoundTagfor the given base and target serializersinput(String key, Consumer<ViaDialogInputBuilder> inputBuilder) Set the input for the dialogopener()Create an opener for the dialogpause(boolean pause) Set the option to pause the game while the dialog is opentitle(com.viaversion.viaversion.libs.mcstructs.text.TextComponent title) Set the title of the dialogSet the title of the dialogprotected abstract voidwriteDialogType(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 thetypekey
-
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 actionscomponentDeserializer- the function to deserialize components from strings
-
-
Method Details
-
deserialize
Deserialize a string to aTextComponent- Parameters:
input- the string to deserialize- Returns:
- the deserialized component
-
title
Set the title of the dialog- Parameters:
title- the title- Returns:
- the dialog itself for method chaining
-
title
Description copied from interface:DialogSet the title of the dialog- Specified by:
titlein interfaceDialog<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
Description copied from interface:DialogSet the external title of the dialog, which is used for displaying the dialog in a multi-dialog dialog- Specified by:
externalTitlein interfaceDialog<ViaItem,ViaDialogBodyBuilder, ViaDialogInputBuilder, T extends ViaDialog<T>> - Parameters:
externalTitle- the external title of the dialog- Returns:
- the dialog itself for method chaining
-
canCloseWithEscape
Description copied from interface:DialogSet the option to allow the dialog to be closed with the escape key- Specified by:
canCloseWithEscapein interfaceDialog<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
Description copied from interface:DialogSet the option to pause the game while the dialog is open- Specified by:
pausein interfaceDialog<ViaItem,ViaDialogBodyBuilder, ViaDialogInputBuilder, T extends ViaDialog<T>> - Parameters:
pause- whether the dialog should pause the game- Returns:
- the dialog itself for method chaining
-
afterAction
Description copied from interface:DialogSet the action to be performed after an action is taken in the dialog- Specified by:
afterActionin interfaceDialog<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
Description copied from interface:DialogSet the body of the dialog- Specified by:
bodyin interfaceDialog<ViaItem,ViaDialogBodyBuilder, ViaDialogInputBuilder, T extends ViaDialog<T>> - Parameters:
bodyBuilder- the body builder for the dialog- Returns:
- the dialog itself for method chaining
-
input
Description copied from interface:DialogSet the input for the dialog- Specified by:
inputin interfaceDialog<ViaItem,ViaDialogBodyBuilder, ViaDialogInputBuilder, T extends ViaDialog<T>> - Parameters:
key- the key for the inputinputBuilder- the input builder for the dialog- Returns:
- the dialog itself for method chaining
-
getActionBuilder
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 thetypekey- Parameters:
tag- the tag to write intobaseVersion- the serializer of the server version the dialog is created fortargetVersion- 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 dialogCompoundTagfor the given base and target protocol versions- Parameters:
baseVersion- the protocol version of the server the dialog is created fortargetVersion- 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 dialogCompoundTagfor the given base and target serializers- Parameters:
baseVersion- the serializer of the server version the dialog is created fortargetVersion- the serializer of the version the dialog is sent to- Returns:
- the dialog tag
-
opener
Description copied from interface:DialogCreate an opener for the dialog- Specified by:
openerin interfaceDialog<ViaItem,ViaDialogBodyBuilder, ViaDialogInputBuilder, T extends ViaDialog<T>> - Returns:
- the dialog opener
-