public class TextUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
java.util.function.UnaryOperator<String> |
CONVERT_OLD_JSON
Coverts the old Json format to the new in-built one.
|
Pattern |
FORMAT_CHAT_PATTERN
The main pattern to identify the custom chat message format in a string.
|
java.util.function.Predicate<String> |
IS_JSON
Check if the line uses a valid json format on any part of the string.
|
java.util.function.BiFunction<org.bukkit.entity.Player,String,String> |
PARSE_INTERACTIVE_CHAT
Parse all the
InteractiveChat values of an input string if
InteractiveChat is enabled. |
java.util.function.BiFunction<org.bukkit.entity.Player,String,String> |
PARSE_PLACEHOLDERAPI
Parse all the
PlaceholderAPI placeholders of an input string if
PlaceholderAPI is enabled. |
java.util.function.UnaryOperator<String> |
STRIP_FIRST_SPACES
Strips the first spaces of an input string.
|
java.util.function.UnaryOperator<String> |
STRIP_JSON
Removes the in-built JSON pattern of a string, if there is any format.
|
Pattern |
URL_PATTERN
A regular expression pattern for matching URLs in a case-insensitive manner.
|
| Constructor and Description |
|---|
TextUtils() |
| Modifier and Type | Method and Description |
|---|---|
String |
convertOldJson(String string)
Deprecated.
|
String |
parseInteractiveChat(org.bukkit.entity.Player player,
String string)
Deprecated.
|
String |
parsePAPI(org.bukkit.entity.Player player,
String string)
Deprecated.
|
String |
removeSpace(String string)
Deprecated.
|
String |
replaceEach(String[] keys,
String[] values,
String string,
boolean b)
Deprecated.
See
ValueReplacer. |
String |
replaceEach(String key,
String value,
String string,
boolean b)
Deprecated.
See
ValueReplacer. |
String |
replaceInsensitiveEach(String[] keys,
String[] values,
String string)
Deprecated.
See
ValueReplacer. |
String |
replaceInsensitiveEach(String key,
String value,
String string)
Deprecated.
See
ValueReplacer. |
boolean |
sendActionBar(org.bukkit.entity.Player player,
String message)
Sends an action bar message to a player.
|
boolean |
sendTitle(org.bukkit.entity.Player player,
@NotNull String[] message,
int in,
int stay,
int out)
Sends a title message to a player.
|
boolean |
sendTitle(org.bukkit.entity.Player player,
String title,
int in,
int stay,
int out)
Sends a title message to a player.
|
boolean |
sendTitle(org.bukkit.entity.Player player,
String title,
String subtitle,
int in,
int stay,
int out)
Sends a title message to a player.
|
String |
stripJson(String string)
Deprecated.
|
@NotNull List<String> |
toList(org.bukkit.configuration.ConfigurationSection section,
String path)
|
List<String> |
toList(org.bukkit.configuration.ConfigurationSection section,
String path,
List<String> def)
|
public final java.util.function.BiFunction<org.bukkit.entity.Player,String,String> PARSE_PLACEHOLDERAPI
PlaceholderAPI placeholders of an input string if
PlaceholderAPI is enabled.
Use the apply(Player, String) method to apply it on a string.
public final java.util.function.BiFunction<org.bukkit.entity.Player,String,String> PARSE_INTERACTIVE_CHAT
InteractiveChat values of an input string if
InteractiveChat is enabled.
Use the apply(Player, String) method to apply it on a string.
public final java.util.function.UnaryOperator<String> STRIP_FIRST_SPACES
Use the apply(String) method to apply it on a string.
public final java.util.function.UnaryOperator<String> CONVERT_OLD_JSON
Use the apply(String) method to apply it on a string.
public final java.util.function.Predicate<String> IS_JSON
Use the apply(String) method to check a string.
public final java.util.function.UnaryOperator<String> STRIP_JSON
Use the apply(String) method to apply it on a string.
public final Pattern URL_PATTERN
The pattern matches URLs that start with an optional protocol (http or https), followed by a domain name consisting of at least two alphanumeric characters, and ending with an optional path.
Note: This pattern is a simplified version that matches basic URL formats and does not handle all possible cases. It may not validate all edge cases or specific scenarios. For more comprehensive URL matching, consider using specialized URL parsing libraries or additional validation.
public final Pattern FORMAT_CHAT_PATTERN
Keep in mind that every string can only have one ClickEvent.Action;
a click action has this format:
Available Actions: RUN, SUGGEST, URL and all ClickAction values.
"<ACTION>:<the click string>" -> "RUN:/me click to run"
// • Examples:
String hover = "<hover:\"a hover line\">text to apply</text>";
String click = "<run:\"/click me\">text to apply</text>";
String mixed = "<hover:\"a hover line<n>another line\"|run:\"/command\">text to apply</text>";
@Deprecated public String parsePAPI(org.bukkit.entity.Player player, String string)
PlaceholderAPI if is enabled.player - a player, can be nullstring - the input line@Deprecated public String parseInteractiveChat(org.bukkit.entity.Player player, String string)
player - the requested playerstring - the line to parse@Deprecated public String removeSpace(String string)
string - the input line@Deprecated public String convertOldJson(String string)
string - an input string@Deprecated public String stripJson(String string)
string - an input string.public List<String> toList(org.bukkit.configuration.ConfigurationSection section, String path, List<String> def)
section - a config file or section, can be nullpath - the path to locate the string or listdef - a default string list if value is not found@NotNull public @NotNull List<String> toList(org.bukkit.configuration.ConfigurationSection section, String path)
section - a config file or section, can be nullpath - the path to locate the string or listpublic boolean sendActionBar(org.bukkit.entity.Player player,
String message)
Doesn't format the message. Use BeansLib.colorize(Player, Player, String).
player - a playermessage - the messagepublic boolean sendTitle(org.bukkit.entity.Player player,
String title,
String subtitle,
int in,
int stay,
int out)
Doesn't format the message. Use BeansLib.colorize(Player, Player, String).
player - a playertitle - a titlesubtitle - a subtitlein - the fadeIn number in ticksstay - the stay number in ticksout - the fadeOut number in tickspublic boolean sendTitle(org.bukkit.entity.Player player,
String title,
int in,
int stay,
int out)
Doesn't format the message. Use BeansLib.colorize(Player, Player, String).
player - a playertitle - a titlein - the fadeIn number in ticksstay - the stay number in ticksout - the fadeOut number in tickspublic boolean sendTitle(org.bukkit.entity.Player player,
@NotNull
@NotNull String[] message,
int in,
int stay,
int out)
Doesn't format the message. Use BeansLib.colorize(Player, Player, String).
player - a playermessage - an array of title and subtitlein - the fadeIn number in ticksstay - the stay number in ticksout - the fadeOut number in ticks@ApiStatus.ScheduledForRemoval(inVersion="1.4") @Deprecated public String replaceEach(String[] keys, String[] values, String string, boolean b)
ValueReplacer.String array of keys with another String
array of values.
Special characters are quoted to avoid errors.
string - an input stringkeys - the array of keysvalues - the array of valuesb - if keys are case-sensitive@ApiStatus.ScheduledForRemoval(inVersion="1.4") @Deprecated public String replaceEach(String key, String value, String string, boolean b)
ValueReplacer.string - an input stringkey - a keyvalue - a valueb - if key is case-sensitive@ApiStatus.ScheduledForRemoval(inVersion="1.4") @Deprecated public String replaceInsensitiveEach(String[] keys, String[] values, String string)
ValueReplacer.String array of keys with another String
array of values.
It's case-insensitive and special characters are quoted to avoid errors.
string - an input stringkeys - the array of keysvalues - the array of values@ApiStatus.ScheduledForRemoval(inVersion="1.4") @Deprecated public String replaceInsensitiveEach(String key, String value, String string)
ValueReplacer.String key with a String value.
It's case-insensitive and special characters are quoted to avoid errors.
string - an input stringkey - a keyvalue - a valueCopyright © 2023. All rights reserved.