Package de.themoep.minedown.adventure
Class MineDownParser
java.lang.Object
de.themoep.minedown.adventure.MineDownParser
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Get whether or not to automatically add http to values of open_url when there doesn't exist any?autoAddUrlPrefix
(boolean autoAddUrlPrefix) Set whether or not to automatically add http to values of open_url when there doesn't exist any?protected net.kyori.adventure.text.ComponentBuilder
<?, ?> builder()
protected MineDownParser
builder
(net.kyori.adventure.text.ComponentBuilder builder) protected net.kyori.adventure.text.event.ClickEvent
protected MineDownParser
clickEvent
(net.kyori.adventure.text.event.ClickEvent clickEvent) char
Get The character to use as a special color code.colorChar
(char colorChar) Set the character to use as a special color code.colors()
protected MineDownParser
copy()
Copy all the parser's setting to a new instancecopy
(boolean formatting) Copy all the parser's setting to a new instancecopy
(MineDownParser from) Copy all the parser's settings from another parser.copy
(MineDownParser from, boolean formatting) Copy all the parser's settings from another parser.disable
(MineDownParser.Option option) Disable an option.enable
(MineDownParser.Option option) Enable an option.Get all enabled options that will be used when parsingenabledOptions
(Set<MineDownParser.Option> enabledOptions) Set all enabled options that will be used when parsing at once, replaces any existing optionsEscape formatting in the string depending on this parser's options.filter
(MineDownParser.Option option) Filter an option.Get all filtered options that will be parsed and then removed from the stringfilteredOptions
(Set<MineDownParser.Option> filteredOptions) Set all filtered options that will be parsed and then removed from the string at once, replaces any existing optionsprotected String
font()
format()
protected MineDownParser
protected boolean
protected MineDownParser
formattingIsLegacy
(boolean formattingIsLegacy) protected net.kyori.adventure.text.event.HoverEvent
protected MineDownParser
hoverEvent
(net.kyori.adventure.text.event.HoverEvent hoverEvent) int
Get the max width the hover text should have.hoverTextWidth
(int hoverTextWidth) Set the max width the hover text should have.protected String
boolean
isEnabled
(MineDownParser.Option option) Check whether or not an option is enabledboolean
isFiltered
(MineDownParser.Option option) Check whether or not an option is filteredboolean
lenient()
Get whether to accept malformed strings or notlenient
(boolean lenient) Set whether to accept malformed strings or notnet.kyori.adventure.text.ComponentBuilder
Create a ComponentBuilder by parsing aMineDown
messagenet.kyori.adventure.text.ComponentBuilder
parseEvent
(String text, String definitions) Parse aMineDown
event stringparseFormat
(String colorString, String prefix, boolean lenient) Parse a color/format definitionprotected Integer
protected MineDownParser
rainbowPhase
(Integer rainbowPhase) reset()
Reset the parser state to the startboolean
Deprecated.translateLegacyColors
(boolean enabled) Deprecated.Useenable(Option)
anddisable(Option)
insteadunfilter
(MineDownParser.Option option) Unfilter an option.boolean
Get whether or not urls in strings are detected and get events added to them?urlDetection
(boolean urlDetection) Set whether or not to detect urls in strings and add events to them?Get the text to display when hovering over an URL.urlHoverText
(String urlHoverText) Set the text to display when hovering over an URL.protected StringBuilder
value()
protected MineDownParser
value
(StringBuilder value)
-
Field Details
-
URL_PATTERN
-
-
Constructor Details
-
MineDownParser
public MineDownParser()
-
-
Method Details
-
parse
public net.kyori.adventure.text.ComponentBuilder parse(String message) throws IllegalArgumentException Create a ComponentBuilder by parsing aMineDown
message- Parameters:
message
- The message to parse- Returns:
- The parsed ComponentBuilder
- Throws:
IllegalArgumentException
- Thrown when a parsing error occurs and lenient is set to false
-
parseEvent
Parse aMineDown
event string- Parameters:
text
- The display textdefinitions
- The event definition string- Returns:
- The parsed ComponentBuilder for this string
-
builder
protected net.kyori.adventure.text.ComponentBuilder<?,?> builder() -
builder
-
value
-
value
-
font
-
insertion
-
colors
protected MineDownParser colors(List<Map.Entry<net.kyori.adventure.text.format.TextColor, Boolean>> colors) -
rainbowPhase
-
rainbowPhase
-
colors
-
format
-
format
-
formattingIsLegacy
-
formattingIsLegacy
protected boolean formattingIsLegacy() -
clickEvent
-
clickEvent
protected net.kyori.adventure.text.event.ClickEvent clickEvent() -
hoverEvent
-
hoverEvent
protected net.kyori.adventure.text.event.HoverEvent hoverEvent() -
parseFormat
public static List<Map.Entry<net.kyori.adventure.text.format.TextFormat,Boolean>> parseFormat(String colorString, String prefix, boolean lenient) Parse a color/format definition- Parameters:
colorString
- The string to parseprefix
- The color prefix e.g. ampersand (&)lenient
- Whether or not to accept malformed strings- Returns:
- The parsed color or
null
if lenient is true and no color was found
-
copy
Copy all the parser's setting to a new instance- Returns:
- The new parser instance with all settings copied
-
copy
Copy all the parser's setting to a new instance- Parameters:
formatting
- Should the formatting be copied too?- Returns:
- The new parser instance with all settings copied
-
copy
Copy all the parser's settings from another parser.- Parameters:
from
- The parser to copy from- Returns:
- This parser's instance
-
copy
Copy all the parser's settings from another parser.- Parameters:
from
- The parser to copy fromformatting
- Should the formatting be copied too?- Returns:
- This parser's instance
-
reset
Reset the parser state to the start- Returns:
- The parser's instance
-
translateLegacyColors
Deprecated.UseisEnabled(Option)
insteadWhether or not to translate legacy color codes (Default: true)- Returns:
- Whether or not to translate legacy color codes (Default: true)
-
translateLegacyColors
Deprecated.Useenable(Option)
anddisable(Option)
insteadWhether or not to translate legacy color codes- Returns:
- The parser
-
isEnabled
Check whether or not an option is enabled- Parameters:
option
- The option to check for- Returns:
true
if it's enabled;false
if not
-
enable
Enable an option.- Parameters:
option
- The option to enable- Returns:
- The parser instace
-
disable
Disable an option. Disabling an option will stop the parser from replacing this option's chars in the string. Usefilter(Option)
to completely remove the characters used by this option from the message instead.- Parameters:
option
- The option to disable- Returns:
- The parser instace
-
isFiltered
Check whether or not an option is filtered- Parameters:
option
- The option to check for- Returns:
true
if it's enabled;false
if not
-
filter
Filter an option. This enables the parsing of an option and completely removes the characters of this option from the string.- Parameters:
option
- The option to add to the filter- Returns:
- The parser instance
-
unfilter
Unfilter an option. Does not enable it!- Parameters:
option
- The option to remove from the filter- Returns:
- The parser instance
-
escape
Escape formatting in the string depending on this parser's options. This will escape backslashes too!- Parameters:
string
- The string to escape- Returns:
- The string with all formatting of this parser escaped
-
colorChar
public char colorChar()Get The character to use as a special color code.- Returns:
- The color character (Default: ampersand &)
-
colorChar
Set the character to use as a special color code.- Parameters:
colorChar
- The color char (Default: ampersand &)- Returns:
- The MineDownParser instance
-
enabledOptions
Get all enabled options that will be used when parsing- Returns:
- a modifiable set of options
-
enabledOptions
Set all enabled options that will be used when parsing at once, replaces any existing options- Parameters:
enabledOptions
- The enabled options- Returns:
- The MineDownParser instance
-
filteredOptions
Get all filtered options that will be parsed and then removed from the string- Returns:
- a modifiable set of options
-
filteredOptions
Set all filtered options that will be parsed and then removed from the string at once, replaces any existing options- Parameters:
filteredOptions
- The filtered options- Returns:
- The MineDownParser instance
-
lenient
public boolean lenient()Get whether to accept malformed strings or not- Returns:
- whether or not the accept malformed strings (Default: false)
-
lenient
Set whether to accept malformed strings or not- Parameters:
lenient
- Set whether or not to accept malformed string (Default: false)- Returns:
- The MineDownParser instance
-
urlDetection
public boolean urlDetection()Get whether or not urls in strings are detected and get events added to them?- Returns:
- whether or not urls are detected (Default: true)
-
urlDetection
Set whether or not to detect urls in strings and add events to them?- Parameters:
urlDetection
- Whether or not to detect urls in strings (Default: true)- Returns:
- The MineDownParser instance
-
urlHoverText
Get the text to display when hovering over an URL. Has a %url% placeholder. -
urlHoverText
Set the text to display when hovering over an URL. Has a %url% placeholder.- Parameters:
urlHoverText
- The url hover text- Returns:
- The MineDownParser instance
-
autoAddUrlPrefix
public boolean autoAddUrlPrefix()Get whether or not to automatically add http to values of open_url when there doesn't exist any?- Returns:
- whether or not to automatically add http to values of open_url when there doesn't exist any? (Default: true)
-
autoAddUrlPrefix
Set whether or not to automatically add http to values of open_url when there doesn't exist any?- Parameters:
autoAddUrlPrefix
- Whether or not automatically add http to values of open_url when there doesn't exist any? (Default: true)- Returns:
- The MineDownParser instance
-
hoverTextWidth
public int hoverTextWidth()Get the max width the hover text should have. Minecraft itself will wrap after 60 characters. Won't apply if the text already includes new lines. -
hoverTextWidth
Set the max width the hover text should have. Minecraft itself will wrap after 60 characters. Won't apply if the text already includes new lines.- Parameters:
hoverTextWidth
- The url hover text length- Returns:
- The MineDownParser instance
-
isEnabled(Option)
instead