Class CopyToClipboard
Purpose: This class is responsible for adding copy-to-clipboard functionality to text within markdown syntax.
When: The copy-to-clipboard action is applied when the text is processed and the feature is enabled.
Where: Executed within the MarkdownParser.parseMarkdown(Component) method when the feature is enabled.
Additional Info: The feature is controlled by the isCopyToClipboardEnabled flag.
Key Methods:
apply(MutableComponent, String)- Applies the copy-to-clipboard functionality to the provided text.isCopyToClipboardEnabled()- Checks if the copy-to-clipboard feature is enabled.
- Since:
- 1.5.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic BooleanFlag that determines whether the copy-to-clipboard feature is enabled. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.network.chat.MutableComponentApplies the copy-to-clipboard functionality to the provided text.static BooleanChecks if the copy-to-clipboard feature is enabled.
-
Field Details
-
isCopyToClipboardEnabled
Flag that determines whether the copy-to-clipboard feature is enabled.Purpose: This variable holds the state of the copy-to-clipboard feature (enabled or disabled).
When: It is checked whenever the markdown text is processed to determine whether the copy-to-clipboard action should be applied.
Where: It is used in theisCopyToClipboardEnabled()method.
Additional Info: This feature can be enabled or disabled globally through this flag.
- Since:
- 1.5.0
- See Also:
-
-
Constructor Details
-
CopyToClipboard
public CopyToClipboard()
-
-
Method Details
-
apply
public net.minecraft.network.chat.MutableComponent apply(net.minecraft.network.chat.MutableComponent pMessage, String pTextToCopy) Applies the copy-to-clipboard functionality to the provided text.Purpose: This method takes the provided text and applies the copy-to-clipboard action, then appends it to the result.
When: Called when processing a markdown string with copy-to-clipboard syntax.
Where: Executed inMarkdownParser.parseMarkdown(Component).
Additional Info: The text is wrapped with a click event that enables copy-to-clipboard.
- Parameters:
pMessage- The message component to be formatted with copy-to-clipboard.pTextToCopy- The text to be copied to clipboard.- Returns:
- The mutable component with the copy-to-clipboard functionality applied.
- Since:
- 1.5.0
- See Also:
-
isCopyToClipboardEnabled
Checks if the copy-to-clipboard feature is enabled.Purpose: Determines whether the copy-to-clipboard feature is active based on the
isCopyToClipboardEnabledflag.
When: Called before processing the text to check if the feature should be applied.
Where: Executed inapply(MutableComponent, String).
Additional Info: This flag can be changed throughisCopyToClipboardEnabled.
- Returns:
trueif copy-to-clipboard is enabled,falseotherwise.- Since:
- 1.5.0
- See Also:
-