Class Hyperlink

java.lang.Object
software.bluelib.markdown.MarkdownFeature
software.bluelib.markdown.syntax.Hyperlink

public class Hyperlink extends MarkdownFeature
A class for handling hyperlink Markdown formatting.

Purpose: This class applies hyperlink formatting to the content of a MutableComponent based on the feature's Prefix and Suffix.
When: The hyperlink formatting is applied when the apply(MutableComponent) method is called.
Where: The formatting is applied to the content of the component and its siblings, if any.
Additional Info: This class supports handling hyperlink Markdown features and can process both single text and text with components.

Key Methods:
Since:
1.4.0
See Also:
  • Field Details

  • Constructor Details

    • Hyperlink

      public Hyperlink()
  • Method Details

    • apply

      public net.minecraft.network.chat.MutableComponent apply(net.minecraft.network.chat.MutableComponent pComponent)
      Applies the hyperlink feature to the provided component.

      Purpose: This method checks whether the feature is enabled and applies the corresponding formatting to the given MutableComponent. If the feature is disabled, it logs an informational message and returns the original component.
      When: The method is called when the hyperlink feature needs to be applied to a component.
      Where: It is called in the MarkdownParser.parseMarkdown(Component) method.
      Additional Info: The method uses a Pattern to find text matching the specified prefix and suffix for hyperlink formatting.

      Overrides:
      apply in class MarkdownFeature
      Parameters:
      pComponent - The component to apply hyperlink formatting to.
      Returns:
      The component with the applied hyperlink formatting.
      Since:
      1.6.0
      See Also:
    • processComponentTextWithHyperlinks

      protected void processComponentTextWithHyperlinks(String pText, net.minecraft.network.chat.Style pOriginalStyle, net.minecraft.network.chat.MutableComponent pResult, Pattern pPattern)
      Processes the text of a component with hyperlink formatting applied.

      Purpose: This method processes the text of a component by applying specific formatting when the hyperlink pattern is matched.
      When: This method is called within MarkdownFeature.processComponentText(java.lang.String, net.minecraft.network.chat.Style, net.minecraft.network.chat.MutableComponent, java.util.regex.Pattern, java.util.function.BiConsumer<java.util.regex.Matcher, net.minecraft.network.chat.MutableComponent>) to handle hyperlink formatting of text.
      Where: It is invoked within the apply(net.minecraft.network.chat.MutableComponent) to process the text of a component.
      Additional Info: The method delegates to appendHyperlink(java.lang.String, java.lang.String, net.minecraft.network.chat.Style, net.minecraft.network.chat.MutableComponent) to apply the formatting for matched text.

      Parameters:
      pText - The text to be processed.
      pOriginalStyle - The original style of the component.
      pResult - The component to append the processed text to.
      pPattern - The pattern used to match hyperlink formatting.
      Since:
      1.6.0
      See Also:
    • processSiblingsWithHyperlinks

      public net.minecraft.network.chat.MutableComponent processSiblingsWithHyperlinks(net.minecraft.network.chat.MutableComponent pComponent, Pattern pPattern)
      Processes the siblings of a component with hyperlink formatting.

      Purpose: This method applies hyperlink formatting to the siblings of a component.
      When: This method is called to process all siblings of a component in hyperlink formatting.
      Where: It is called from apply(MutableComponent) and related methods.
      Additional Info: The method iterates over all siblings and applies formatting to each of them individually.

      Parameters:
      pComponent - The component whose siblings will be processed.
      pPattern - The pattern used to match hyperlink formatting.
      Returns:
      The component with formatted siblings.
      Since:
      1.6.0
      See Also:
    • isFeatureEnabled

      protected boolean isFeatureEnabled()
      Checks if the hyperlink feature is enabled.

      Purpose: This method checks if the feature is enabled and returns the result.
      When: It is called to determine if the feature is enabled.
      Where: It is invoked in apply(MutableComponent) to check if the feature is enabled.
      Additional Info: The method is overridden in subclasses to check the specific feature's status.

      Specified by:
      isFeatureEnabled in class MarkdownFeature
      Returns:
      true if the feature is enabled; false otherwise.
      Since:
      1.6.0
      See Also:
    • getFeatureName

      protected String getFeatureName()
      Gets the name of the feature.

      Purpose: This method returns the name of the feature.
      When: It is called to get the name of the feature.
      Where: It is invoked in apply(MutableComponent) to log an informational message.
      Additional Info: The method is overridden in subclasses to return the specific feature's name.

      Specified by:
      getFeatureName in class MarkdownFeature
      Returns:
      The name of the feature.
      Since:
      1.6.0
      See Also:
    • setPrefixSuffix

      public static void setPrefixSuffix(String pPrefix, String pSuffix)
      Sets the prefix and suffix used for hyperlink formatting.

      Purpose: This method allows the user to set both the prefix and suffix for hyperlink formatting.
      When: It is called to customize the prefix and suffix.
      Where: Can be invoked from any class or method.
      Additional Info: The updated prefix and suffix will affect all instances of the Hyperlink feature.

      Parameters:
      pPrefix - The new prefix for hyperlink.
      pSuffix - The new suffix for hyperlink.
      Since:
      1.4.0
      See Also:
    • setPrefix

      public static void setPrefix(String pPrefix)
      Sets the prefix used for hyperlink formatting.

      Purpose: This method allows the user to set the prefix for hyperlink formatting.
      When: It is called to customize the prefix.
      Where: Can be invoked from any class or method.
      Additional Info: The updated prefix will affect all instances of the Hyperlink feature.

      Parameters:
      pPrefix - The new prefix for hyperlink.
      Since:
      1.4.0
      See Also:
    • setSuffix

      public static void setSuffix(String pSuffix)
      Sets the suffix used for hyperlink formatting.

      Purpose: This method allows the user to set the suffix for hyperlink formatting.
      When: It is called to customize the suffix.
      Where: Can be invoked from any class or method.
      Additional Info: The updated suffix will affect all instances of the Hyperlink feature.

      Parameters:
      pSuffix - The new suffix for hyperlink.
      Since:
      1.4.0
      See Also:
    • getPrefix

      public static String getPrefix()
      Gets the prefix used for hyperlink formatting.

      Purpose: This method returns the current prefix used for hyperlink formatting.
      When: It is called to retrieve the prefix.
      Where: Can be invoked from any class or method.
      Additional Info: This returns the default or custom prefix depending on prior settings.

      Returns:
      The current prefix used for hyperlink.
      Since:
      1.4.0
      See Also:
    • getSuffix

      public static String getSuffix()
      Gets the suffix used for hyperlink formatting.

      Purpose: This method returns the current suffix used for hyperlink formatting.
      When: It is called to retrieve the suffix.
      Where: Can be invoked from any class or method.
      Additional Info: This returns the default or custom suffix depending on prior settings.

      Returns:
      The current suffix used for hyperlink.
      Since:
      1.4.0
      See Also:
    • isHyperlinkEnabled

      public static Boolean isHyperlinkEnabled()
      Checks if the hyperlink feature is enabled.

      Purpose: This method returns the current state of the hyperlink feature (enabled or disabled).
      When: It is called to check if the hyperlink feature is enabled.
      Where: Can be invoked from any class or method.
      Additional Info: This method reflects the current state of the isHyperlinkEnabled flag.

      Returns:
      true if the hyperlink feature is enabled, false otherwise.
      Since:
      1.4.0
      See Also: