Class MarkdownFeature
public abstract class for handling Markdown formatting features.
Purpose: This class applies specific formatting to the content of a MutableComponent based on the feature's prefix and suffix. It handles both plain text and components with siblings.
When: The Markdown 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 different types of Markdown features (e.g., bold, italic) and can process both single text and text with components.
apply(MutableComponent)- Applies the Markdown feature to a given component.processComponentText(String, Style, MutableComponent, Pattern, BiConsumer)- Processes text with Markdown formatting.processComponentTextWithFormatting(String, Style, MutableComponent, Pattern)- Processes text with specific formatting.processSiblings(MutableComponent, Pattern, QuadConsumer)- Processes siblings of a component with Markdown formatting.processSiblingsWithFormatting(MutableComponent, Pattern)- Processes siblings with specific Markdown formatting.appendFormattedText(String, Style, MutableComponent)- Appends formatted text to a component.appendUnstyledText(String, MutableComponent, Style)- Appends unstyled text to a component.isFeatureEnabled()- Checks if the feature is enabled.getFeatureName()- Gets the name of the feature.
- Since:
- 1.1.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendFormattedText(String pText, net.minecraft.network.chat.Style pStyle, net.minecraft.network.chat.MutableComponent pResult) Appends formatted text to a component.protected voidappendUnstyledText(String pText, net.minecraft.network.chat.MutableComponent pResult, net.minecraft.network.chat.Style pOriginalStyle) Appends unstyled text to a component.net.minecraft.network.chat.MutableComponentapply(net.minecraft.network.chat.MutableComponent pComponent) Applies the Markdown feature to the provided component.protected abstract StringGets the name of the feature.protected abstract booleanChecks if the feature is enabled.protected voidprocessComponentText(String pText, net.minecraft.network.chat.Style pOriginalStyle, net.minecraft.network.chat.MutableComponent pResult, Pattern pPattern, BiConsumer<Matcher, net.minecraft.network.chat.MutableComponent> pSpecialTextHandler) Processes the text of a component using Markdown formatting.protected voidprocessComponentTextWithFormatting(String pText, net.minecraft.network.chat.Style pOriginalStyle, net.minecraft.network.chat.MutableComponent pResult, Pattern pPattern) Processes the text of a component with Markdown formatting applied.protected net.minecraft.network.chat.MutableComponentprocessSiblings(net.minecraft.network.chat.MutableComponent pComponent, Pattern pPattern, QuadConsumer<String, net.minecraft.network.chat.Style, net.minecraft.network.chat.MutableComponent, Pattern> pSiblingProcessor) Processes the siblings of a component with Markdown formatting.protected net.minecraft.network.chat.MutableComponentprocessSiblingsWithFormatting(net.minecraft.network.chat.MutableComponent pComponent, Pattern pPattern) Processes the siblings of a component with specific Markdown formatting applied.
-
Field Details
-
prefix
The prefix for the Markdown feature.Purpose: This field stores the prefix for the Markdown feature, which is used to identify the start of the formatted text.
When: The prefix is used to identify the start of the formatted text in the content.
Where: It is used in theapply(MutableComponent)method to apply the Markdown feature.
Additional Info: The prefix is used to identify the start of the formatted text, which is then processed accordingly.
- Since:
- 1.1.0
-
suffix
The suffix for the Markdown feature.Purpose: This field stores the suffix for the Markdown feature, which is used to identify the end of the formatted text.
When: The suffix is used to identify the end of the formatted text in the content.
Where: It is used in theapply(MutableComponent)method to apply the Markdown feature.
Additional Info: The suffix is used to identify the end of the formatted text, which is then processed accordingly.
- Since:
- 1.1.0
-
-
Constructor Details
-
MarkdownFeature
public MarkdownFeature()
-
-
Method Details
-
apply
public net.minecraft.network.chat.MutableComponent apply(net.minecraft.network.chat.MutableComponent pComponent) Applies the Markdown 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 Markdown feature needs to be applied to a component.
Where: It is called in theMarkdownParser.parseMarkdown(Component)method.
Additional Info: The method uses aPatternto find text matching the specified prefix and suffix for Markdown formatting.
- Parameters:
pComponent- The component to apply Markdown formatting to.- Returns:
- The component with the applied Markdown formatting.
- Since:
- 1.6.0
- See Also:
-
processComponentText
protected void processComponentText(String pText, net.minecraft.network.chat.Style pOriginalStyle, net.minecraft.network.chat.MutableComponent pResult, Pattern pPattern, BiConsumer<Matcher, net.minecraft.network.chat.MutableComponent> pSpecialTextHandler) Processes the text of a component using Markdown formatting.Purpose: This method applies Markdown formatting to the text in a
MutableComponentbased on a specified pattern and special text handler.
When: This method is called when processing the text of a component for Markdown formatting.
Where: It is invoked inapply(MutableComponent)or related methods to process the component's text.
Additional Info: This method handles escaping of special characters and applies formatting only to text matching the pattern.
- 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 Markdown formatting.pSpecialTextHandler- A handler to apply special formatting.- Since:
- 1.6.0
- See Also:
-
processComponentTextWithFormatting
protected void processComponentTextWithFormatting(String pText, net.minecraft.network.chat.Style pOriginalStyle, net.minecraft.network.chat.MutableComponent pResult, Pattern pPattern) Processes the text of a component with Markdown formatting applied.Purpose: This method processes the text of a component by applying specific formatting when the Markdown pattern is matched.
When: This method is called withinprocessComponentText(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 Markdown formatting of text.
Where: It is invoked within theapply(net.minecraft.network.chat.MutableComponent)to process the text of a component.
Additional Info: The method delegates toappendFormattedText(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 Markdown formatting.- Since:
- 1.6.0
- See Also:
-
processSiblings
protected net.minecraft.network.chat.MutableComponent processSiblings(net.minecraft.network.chat.MutableComponent pComponent, Pattern pPattern, QuadConsumer<String, net.minecraft.network.chat.Style, net.minecraft.network.chat.MutableComponent, Pattern> pSiblingProcessor) Processes the siblings of a component with Markdown formatting.Purpose: This method applies Markdown formatting to the siblings of a component.
When: This method is called to process all siblings of a component in Markdown formatting.
Where: It is called fromapply(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 Markdown formatting.pSiblingProcessor- A consumer for processing each sibling's text with Markdown formatting.- Returns:
- The component with formatted siblings.
- Since:
- 1.6.0
- See Also:
-
processSiblingsWithFormatting
protected net.minecraft.network.chat.MutableComponent processSiblingsWithFormatting(net.minecraft.network.chat.MutableComponent pComponent, Pattern pPattern) Processes the siblings of a component with specific Markdown formatting applied.Purpose: This method applies Markdown formatting to all siblings of a component.
When: It is called to apply formatting to the siblings of the component in theapply(MutableComponent)method.
Where: It is invoked fromprocessSiblings(net.minecraft.network.chat.MutableComponent, java.util.regex.Pattern, software.bluelib.utils.QuadConsumer<java.lang.String, net.minecraft.network.chat.Style, net.minecraft.network.chat.MutableComponent, java.util.regex.Pattern>)to handle sibling components.
Additional Info: The method usesprocessComponentTextWithFormatting(java.lang.String, net.minecraft.network.chat.Style, net.minecraft.network.chat.MutableComponent, java.util.regex.Pattern)to handle the text formatting.
- Parameters:
pComponent- The component whose siblings will be formatted.pPattern- The pattern used to match Markdown formatting.- Returns:
- The component with formatted siblings.
- Since:
- 1.6.0
- See Also:
-
appendFormattedText
protected void appendFormattedText(String pText, net.minecraft.network.chat.Style pStyle, net.minecraft.network.chat.MutableComponent pResult) Appends formatted text to a component.Purpose: This method appends formatted text to a component, applying the specified style.
When: This method is called when the Markdown feature needs to format and append text.
Where: It is invoked inprocessComponentTextWithFormatting(java.lang.String, net.minecraft.network.chat.Style, net.minecraft.network.chat.MutableComponent, java.util.regex.Pattern)to handle formatted text.
Additional Info: The method ensures that the appropriate style is applied to the appended text.
- Parameters:
pText- The text to be appended.pStyle- The style to be applied to the text.pResult- The component to append the formatted text to.- Since:
- 1.6.0
- See Also:
-
appendUnstyledText
protected void appendUnstyledText(String pText, net.minecraft.network.chat.MutableComponent pResult, net.minecraft.network.chat.Style pOriginalStyle) Appends unstyled text to a component.Purpose: This method appends unstyled text to a component.
When: This method is called when plain, unstyled text needs to be appended.
Where: It is invoked within other methods likeprocessComponentText(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 append plain text.
Additional Info: The method adds the unstyled text directly without modifying the component's style.
- Parameters:
pText- The text to be appended.pResult- The component to append the unstyled text to.pOriginalStyle- The original style for the text.- Since:
- 1.6.0
- See Also:
-
isFeatureEnabled
protected abstract boolean isFeatureEnabled()Checks if the 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 inapply(MutableComponent)to check if the feature is enabled.
Additional Info: The method is overridden in subclasses to check the specific feature's status.
- Returns:
trueif the feature is enabled;falseotherwise.- Since:
- 1.6.0
- See Also:
-
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 inapply(MutableComponent)to log an informational message.
Additional Info: The method is overridden in subclasses to return the specific feature's name.
- Returns:
- The name of the feature.
- Since:
- 1.6.0
- See Also:
-