public class Beans extends Object
| Constructor and Description |
|---|
Beans() |
| Modifier and Type | Method and Description |
|---|---|
String |
colorize(org.bukkit.entity.Player target,
org.bukkit.entity.Player parser,
String string)
Formats an input string parsing first
PlaceholderAPI placeholders,
replaced chars and then applying the respective colors. |
String |
colorize(org.bukkit.entity.Player player,
String string)
Formats an input string parsing first
PlaceholderAPI placeholders,
replaced chars and then applying the respective colors. |
String |
colorize(String string)
Formats an input string parsing first
PlaceholderAPI placeholders,
replaced chars and then applying the respective colors. |
String |
convertToSmallCaps(String string) |
String |
createCenteredChatMessage(org.bukkit.entity.Player target,
org.bukkit.entity.Player parser,
String string)
Formats a string to a centered string, that has a perfect amount of spaces
before the actual string to be display in the chat as a centered message.
|
String |
createCenteredChatMessage(org.bukkit.entity.Player player,
String string)
Formats a string to a centered string, that has a perfect amount of spaces
before the actual string to be display in the chat as a centered message.
|
String |
createCenteredChatMessage(String string)
Formats a string to a centered string, that has a perfect amount of spaces
before the actual string to be display in the chat as a centered message.
|
void |
doLog(@Nullable org.bukkit.command.CommandSender sender,
String... lines)
Sends requested information to a
CommandSender using the plugin's
logger and its prefix. |
void |
doLog(String... lines)
Sends requested information to a
CommandSender using the plugin's
logger and its prefix. |
String |
formatPlaceholders(@Nullable org.bukkit.entity.Player parser,
String string) |
Pattern |
getBlankPattern()
Creates a new
Pattern instance using the defined blank-space
internal placeholder. |
Pattern |
getBossbarPattern()
Creates a new
Pattern instance using the defined custom bossbar
internal placeholder. |
org.bukkit.configuration.ConfigurationSection |
getBossbarSection()
The
ConfigurationSection object to get all the custom bossbars. |
String |
getCenterPrefix()
The center prefix to define a center chat message.
|
Pattern |
getCharPattern()
Creates a new
Pattern instance using the defined char regex string. |
int[] |
getDefaultTitleTicks()
In, stay and out ticks for a title message.
|
String[] |
getKeysDelimiters()
The delimiters of all the messages keys to identify what type of
message is a string to be displayed.
|
String |
getLangPrefix()
The plugin's prefix that will replace the prefix key:
getLangPrefixKey(). |
String |
getLangPrefixKey()
A key that will be replaced by the main plugin prefix:
getLangPrefix(). |
String |
getLineSeparator()
The line splitter or separator to split multiple chat lines or split a title
message between title and subtitle.
|
@NotNull BeansLib |
getLoaded()
Returns the static instance of the lib that is loaded by a plugin using this lib.
|
@NotNull org.bukkit.plugin.Plugin |
getPlugin()
The
Plugin instance of your project. |
Pattern |
getSmallCapsPattern()
Creates a new
Pattern instance using the defined SmallCaps
internal placeholder. |
org.bukkit.configuration.ConfigurationSection |
getWebhookSection()
The
ConfigurationSection object to get all the available webhooks. |
void |
mixLog(org.bukkit.command.CommandSender sender,
String... lines)
Sends information choosing which of the two main methods will be used in each line.
|
void |
mixLog(String... lines)
Sends information choosing which of the two main methods will be used in each line.
|
String |
parseChars(String string)
Use a char pattern to find unicode values and replace them with
its respective characters.
|
void |
playerLog(@NotNull org.bukkit.entity.Player player,
String... lines)
Sends information to a player using the
MessageSender object. |
void |
rawLog(String... lines)
Sends requested information using
Bukkit.getLogger() to the console,
avoiding the plugin prefix. |
String |
replacePrefixKey(String string,
boolean remove)
Replace the
BeansLib.langPrefixKey with the BeansLib.langPrefix. |
void |
setLib(BeansLib lib) |
String[] |
splitLine(String s)
Creates a new string array from an input string using the
getLineSeparator()
as a split for the array. |
String[] |
splitLine(String s,
int limit)
Creates a new string array from an input string using the
getLineSeparator()
as a split for the array. |
public void setLib(BeansLib lib)
public String getLangPrefix()
getLangPrefixKey().public String getLangPrefixKey()
getLangPrefix().public String getCenterPrefix()
public String getLineSeparator()
If you want to override this string, the custom separator should be quoted
using Pattern.quote(String).
// Example of how setting a custom separator
lib.setLineSeparator(Pattern.quote("{split}"));
public org.bukkit.configuration.ConfigurationSection getWebhookSection()
ConfigurationSection object to get all the available webhooks.public org.bukkit.configuration.ConfigurationSection getBossbarSection()
ConfigurationSection object to get all the custom bossbars.public int[] getDefaultTitleTicks()
int[] ticks = defaultTitleTicks();
// Respective values
int fadeIn = ticks[0];
int stay = ticks[1];
int fadeout = ticks[2];
public String[] getKeysDelimiters()
Example: default: [title] - custom: {{title}}
public Pattern getCharPattern()
Pattern instance using the defined char regex string.public Pattern getBossbarPattern()
Pattern instance using the defined custom bossbar
internal placeholder.public Pattern getBlankPattern()
Pattern instance using the defined blank-space
internal placeholder.public Pattern getSmallCapsPattern()
Pattern instance using the defined SmallCaps
internal placeholder.@NotNull
public @NotNull org.bukkit.plugin.Plugin getPlugin()
throws NullPointerException
Plugin instance of your project.NullPointerException - if the plugin is nullpublic String replacePrefixKey(String string, boolean remove)
BeansLib.langPrefixKey with the BeansLib.langPrefix.string - an input stringremove - if the prefix will be removedpublic String[] splitLine(String s, int limit)
getLineSeparator()
as a split for the array.
You can define the limit of the array.
s - an input stringlimit - a limitpublic String[] splitLine(String s)
getLineSeparator()
as a split for the array.s - an input stringpublic String parseChars(String string)
string - the input linepublic String formatPlaceholders(@Nullable @Nullable org.bukkit.entity.Player parser, String string)
public String colorize(org.bukkit.entity.Player target, org.bukkit.entity.Player parser, String string)
PlaceholderAPI placeholders,
replaced chars and then applying the respective colors.target - a target to parse colors depending on its client, can be nullparser - a player, can be nullstring - the input messagepublic String colorize(org.bukkit.entity.Player player, String string)
PlaceholderAPI placeholders,
replaced chars and then applying the respective colors.player - a player, can be nullstring - the input messagepublic String colorize(String string)
PlaceholderAPI placeholders,
replaced chars and then applying the respective colors.string - the input messagepublic String createCenteredChatMessage(org.bukkit.entity.Player target, org.bukkit.entity.Player parser, String string)
target - a target to parse colors depending on its client, can be nullparser - a player to parse placeholders.string - the input messagepublic String createCenteredChatMessage(org.bukkit.entity.Player player, String string)
player - a player to parse placeholders.string - the input messagepublic String createCenteredChatMessage(String string)
string - the input messagepublic void playerLog(@NotNull
@NotNull org.bukkit.entity.Player player,
String... lines)
MessageSender object.player - a valid playerlines - the information to sendpublic void rawLog(String... lines)
Bukkit.getLogger() to the console,
avoiding the plugin prefix.lines - the information to sendpublic void doLog(@Nullable
@Nullable org.bukkit.command.CommandSender sender,
String... lines)
CommandSender using the plugin's
logger and its prefix.
If the sender is a Player and it's not null, it will log using
playerLog(Player, String...).
sender - a valid sender, can be the console, a player or nulllines - the information to sendNullPointerException - if the plugin is nullpublic void doLog(String... lines)
CommandSender using the plugin's
logger and its prefix.lines - the information to sendNullPointerException - if the plugin is nullpublic void mixLog(org.bukkit.command.CommandSender sender,
String... lines)
rawLog, doLog)
If the line does not start with a boolean value or that value is false,
it will use the doLog method, otherwise
will use the rawLog method.
"My information for the console" >> // Uses "doLog"
"true::My basic log information" >> // Uses "rawLog"
"false::Some plugin's information" >> // Uses "doLog"
"" or null >> // Uses "doLog", 'cause is empty/null
sender - a valid sender, can be the console, a player or nulllines - the information to sendpublic void mixLog(String... lines)
rawLog, doLog)
If the line does not start with a boolean value or that value is false,
it will use the doLog method, otherwise
will use the rawLog method.
"My information for the console" >> // Uses "doLog"
"true::My basic log information" >> // Uses "rawLog"
"false::Some plugin's information" >> // Uses "doLog"
"" or null >> // Uses "doLog", 'cause is empty/null
lines - the information to send@NotNull public @NotNull BeansLib getLoaded()
NO_PLUGIN_INSTANCE.
To avoid the no-plugin result, a lib instance should be initialized in the
main class of the project, on JavaPlugin.onLoad() or JavaPlugin.onEnable().
"Initialization example of the lib in the main plugin class"
public void onEnable() {
BeansLib lib = new BeansLib(this);
// or this
BeansLib lib = new BeansLib();
}
Methods that depends on the plugin's instance, such as doLog(String...),
will throw an NullPointerException if the NO_PLUGIN_INSTANCE is
returned or if the instance has no plugin implementation.Copyright © 2023. All rights reserved.