Class CopyToClipboard

java.lang.Object
software.bluelib.markdown.syntax.CopyToClipboard

public class CopyToClipboard extends Object
Handles the application of the copy-to-clipboard feature to Markdown text.

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:

Since:
1.5.0
See Also:
  • Field Details

    • isCopyToClipboardEnabled

      public static Boolean 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 the isCopyToClipboardEnabled() 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 in MarkdownParser.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

      public static Boolean isCopyToClipboardEnabled()
      Checks if the copy-to-clipboard feature is enabled.

      Purpose: Determines whether the copy-to-clipboard feature is active based on the isCopyToClipboardEnabled flag.
      When: Called before processing the text to check if the feature should be applied.
      Where: Executed in apply(MutableComponent, String).
      Additional Info: This flag can be changed through isCopyToClipboardEnabled.

      Returns:
      true if copy-to-clipboard is enabled, false otherwise.
      Since:
      1.5.0
      See Also: