Class Color

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

public class Color extends MarkdownFeature
A class for handling color formatting in Markdown.

Purpose: This class applies color formatting to the content of a MutableComponent based on the feature's Prefix and Suffix.
When: The color 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 color formatting in Markdown and can process both single text and text with components.

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

  • Constructor Details

    • Color

      public Color()
  • Method Details

    • apply

      public net.minecraft.network.chat.MutableComponent apply(net.minecraft.network.chat.MutableComponent pComponent)
      Applies the color 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 color feature needs to be applied to a component.
      Where: It is called in the MarkdownFeature.apply(MutableComponent) method.
      Additional Info: The method uses a Pattern to find text matching the specified prefix and suffix for color formatting.

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

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

      Purpose: This method processes the text of a component by applying specific formatting when the color 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 color 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 appendColor(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 color formatting.
      Since:
      1.6.0
      See Also:
    • processSiblingsWithColors

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

      Purpose: This method applies color formatting to the siblings of a component.
      When: This method is called to process all siblings of a component in color 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 color formatting.
      Returns:
      The component with formatted siblings.
      Since:
      1.6.0
      See Also:
    • isFeatureEnabled

      protected boolean isFeatureEnabled()
      Checks if the color 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 color formatting.

      Purpose: This method allows the user to set both the prefix and suffix for color 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 Color feature.

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

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

      Purpose: This method allows the user to set the prefix for color 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 Color feature.

      Parameters:
      pPrefix - The new prefix for color.
      Since:
      1.6.0
      See Also:
    • setSuffix

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

      Purpose: This method allows the user to set the suffix for color 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 Color feature.

      Parameters:
      pSuffix - The new suffix for color.
      Since:
      1.6.0
      See Also:
    • getPrefix

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

      Purpose: This method returns the current prefix used for color 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 color.
      Since:
      1.6.0
      See Also:
    • getSuffix

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

      Purpose: This method returns the current suffix used for color 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 color.
      Since:
      1.6.0
      See Also:
    • isColorEnabled

      public static Boolean isColorEnabled()
      Checks if the color feature is enabled.

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

      Returns:
      true if the color feature is enabled, false otherwise.
      Since:
      1.6.0
      See Also: