Class Hyperlink
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.
apply(MutableComponent)- Applies the hyperlink feature to a given component.processComponentTextWithHyperlinks(String, Style, MutableComponent, Pattern)- Processes text with hyperlink formatting.processSiblingsWithHyperlinks(MutableComponent, Pattern)- Processes siblings with hyperlink formatting.appendHyperlink(String, String, Style, MutableComponent)- Appends hyperlink formatted text to a component.isFeatureEnabled()- Checks if the feature is enabled.getFeatureName()- Gets the name of the feature.setPrefixSuffix(String, String)- Sets the prefix and suffix for hyperlink formatting.setPrefix(String)- Sets the prefix for hyperlink formatting.setSuffix(String)- Sets the suffix for hyperlink formatting.getPrefix()- Gets the prefix for hyperlink formatting.getSuffix()- Gets the suffix for hyperlink formatting.isHyperlinkEnabled()- Checks if the hyperlink feature is enabled.
- Since:
- 1.4.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic BooleanFlag that determines whether the hyperlink feature is enabled.protected static StringThe prefix for the hyperlink feature.protected static StringThe suffix for the hyperlink feature.Fields inherited from class software.bluelib.markdown.MarkdownFeature
prefix, suffix -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.network.chat.MutableComponentapply(net.minecraft.network.chat.MutableComponent pComponent) Applies the hyperlink feature to the provided component.protected StringGets the name of the feature.static StringGets the prefix used for hyperlink formatting.static StringGets the suffix used for hyperlink formatting.protected booleanChecks if the hyperlink feature is enabled.static BooleanChecks if the hyperlink feature is enabled.protected voidprocessComponentTextWithHyperlinks(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.net.minecraft.network.chat.MutableComponentprocessSiblingsWithHyperlinks(net.minecraft.network.chat.MutableComponent pComponent, Pattern pPattern) Processes the siblings of a component with hyperlink formatting.static voidSets the prefix used for hyperlink formatting.static voidsetPrefixSuffix(String pPrefix, String pSuffix) Sets the prefix and suffix used for hyperlink formatting.static voidSets the suffix used for hyperlink formatting.Methods inherited from class software.bluelib.markdown.MarkdownFeature
appendFormattedText, appendUnstyledText, processComponentText, processComponentTextWithFormatting, processSiblings, processSiblingsWithFormatting
-
Field Details
-
Prefix
The prefix for the hyperlink feature.Purpose: This field stores the prefix for the hyperlink 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 hyperlink feature.
Additional Info: The prefix is used to identify the start of the formatted text, which is then processed accordingly.
- Since:
- 1.4.0
- See Also:
-
Suffix
The suffix for the hyperlink feature.Purpose: This field stores the suffix for the hyperlink 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 hyperlink feature.
Additional Info: The suffix is used to identify the end of the formatted text, which is then processed accordingly.
- Since:
- 1.4.0
- See Also:
-
isHyperlinkEnabled
Flag that determines whether the hyperlink feature is enabled.Purpose: This variable holds the state of the hyperlink feature (enabled or disabled).
When: It is checked whenever the markdown text is processed to determine whether the hyperlink should be applied.
Where: It is used in theisFeatureEnabled()andisHyperlinkEnabled()methods.
Additional Info: This feature can be enabled or disabled globally through this flag.
- Since:
- 1.4.0
- See Also:
-
-
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 theMarkdownParser.parseMarkdown(Component)method.
Additional Info: The method uses aPatternto find text matching the specified prefix and suffix for hyperlink formatting.
- Overrides:
applyin classMarkdownFeature- 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 withinMarkdownFeature.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 theapply(net.minecraft.network.chat.MutableComponent)to process the text of a component.
Additional Info: The method delegates toappendHyperlink(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 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 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 inapply(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:
isFeatureEnabledin classMarkdownFeature- 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.
- Specified by:
getFeatureNamein classMarkdownFeature- Returns:
- The name of the feature.
- Since:
- 1.6.0
- See Also:
-
setPrefixSuffix
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 theHyperlinkfeature.
- Parameters:
pPrefix- The new prefix for hyperlink.pSuffix- The new suffix for hyperlink.- Since:
- 1.4.0
- See Also:
-
setPrefix
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 theHyperlinkfeature.
- Parameters:
pPrefix- The new prefix for hyperlink.- Since:
- 1.4.0
- See Also:
-
setSuffix
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 theHyperlinkfeature.
- Parameters:
pSuffix- The new suffix for hyperlink.- Since:
- 1.4.0
- See Also:
-
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
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
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 theisHyperlinkEnabledflag.
- Returns:
trueif the hyperlink feature is enabled,falseotherwise.- Since:
- 1.4.0
- See Also:
-