CommandAPI 9.6.0
An API for the command UI introduced in Minecraft 1.13
dev.jorel.commandapi.arguments.Previewable< T, A > Interface Template Reference

An interface representing that the argument can be previewed using Minecraft's chat preview feature. More...

Public Member Functions

withPreview (PreviewableFunction< A > preview)
 Sets the PreviewableFunction for this argument. More...
 
Optional< PreviewableFunction< A > > getPreview ()
 
usePreview (boolean usePreview)
 Whether this argument should use the preview result as the argument value for execution. More...
 
boolean isLegacy ()
 

Detailed Description

An interface representing that the argument can be previewed using Minecraft's chat preview feature.

To use this, the server must have previews-chat=true set in its server.properties file

Member Function Documentation

◆ getPreview()

Optional< PreviewableFunction< A > > dev.jorel.commandapi.arguments.Previewable< T, A >.getPreview ( )
Returns
the PreviewableFunction for this argument, as an Optional.

◆ isLegacy()

boolean dev.jorel.commandapi.arguments.Previewable< T, A >.isLegacy ( )
Returns
whether this argument uses legacy chat component APIs

◆ usePreview()

T dev.jorel.commandapi.arguments.Previewable< T, A >.usePreview ( boolean  usePreview)

Whether this argument should use the preview result as the argument value for execution.

If set to true, accessing this argument in args will return the same value generated from Previewable#withPreview(PreviewableFunction)

Parameters
usePreviewwhether to use the preview as the value for this argument
Returns
the current argument

◆ withPreview()

T dev.jorel.commandapi.arguments.Previewable< T, A >.withPreview ( PreviewableFunction< A >  preview)

Sets the PreviewableFunction for this argument.

This function will run when a player requests a chat preview from the server. The function's PreviewInfo will be populated based on the input for the relevant player that requests the chat preview.

Parameters
previewthe function to use for chat preview generation
Returns
the current argument