public abstract class MessageExecutor extends Object implements Cloneable
MessageExecutor class manages how to identify a message type if it has
a respective registered prefix and an optional additional regex parameter to check
if more arguments will be needed to identify the message type.
Each default instance of this class have a setter for the main key and the regex,
if It's necessary to change those values.
The default key and regex of each instance depends mostly on the Beans.getLoaded().
This class can not have more instances or child classes to avoid errors with the existing keys.
See MessageSender, it uses the default instances to parse, format, and
send messages to players.
| Modifier and Type | Field and Description |
|---|---|
static MessageExecutor |
ACTION_BAR_EXECUTOR
The
MessageExecutor instance to identify action-bar messages. |
static MessageExecutor |
BOSSBAR_EXECUTOR
The
MessageExecutor instance to identify minecraft bossbar messages. |
static MessageExecutor |
CHAT_EXECUTOR
The
MessageExecutor instance to identify default chat messages. |
static MessageExecutor |
JSON_EXECUTOR
The
MessageExecutor instance to identify vanilla json messages. |
static MessageExecutor |
TITLE_EXECUTOR
The
MessageExecutor instance to identify title and subtitle messages. |
static MessageExecutor |
WEBHOOK_EXECUTOR
The
MessageExecutor instance to identify discord webhook messages. |
| Modifier and Type | Method and Description |
|---|---|
protected @NotNull MessageExecutor |
clone()
Creates and returns a copy of this key.
|
abstract boolean |
execute(org.bukkit.entity.Player target,
org.bukkit.entity.Player parser,
String string)
Executes the defined action of this representation.
|
boolean |
execute(org.bukkit.entity.Player parser,
String string)
Executes the defined action of this representation.
|
static MessageExecutor |
fromFlag(MessageFlag flag) |
Pattern |
getPattern()
Returns a
Pattern instance using the defined key and the
optional defined regex. |
static @NotNull MessageExecutor |
identifyKey(String s)
Returns the key instance of an input string to check what message type
is the string.
|
static @NotNull MessageExecutor |
matchKey(String string)
Returns the key instance of an input key that could match with any existing
defined key.
|
static void |
setDefaults()
Rollbacks any change in the default keys stored.
|
public static final MessageExecutor ACTION_BAR_EXECUTOR
MessageExecutor instance to identify action-bar messages.public static final MessageExecutor TITLE_EXECUTOR
MessageExecutor instance to identify title and subtitle messages.
By default has a regex string to catch how many seconds the title will be displayed.
public static final MessageExecutor WEBHOOK_EXECUTOR
MessageExecutor instance to identify discord webhook messages.
By default has a regex string to catch the configuration path of the webhook.
public static final MessageExecutor JSON_EXECUTOR
MessageExecutor instance to identify vanilla json messages.public static final MessageExecutor BOSSBAR_EXECUTOR
MessageExecutor instance to identify minecraft bossbar messages.
By default has a regex string to catch the configuration path of the custom bossbar, or to catch the arguments of the bossbar message.
public static final MessageExecutor CHAT_EXECUTOR
MessageExecutor instance to identify default chat messages.
It's not necessary to identify a string with this prefix; because if a string doesn't have a prefix, it will by default a chat message.
The setters of this instance will throw an UnsupportedOperationException.
@NotNull protected @NotNull MessageExecutor clone()
public abstract boolean execute(org.bukkit.entity.Player target,
org.bukkit.entity.Player parser,
String string)
target - a target playerparser - a player to parse argumentsstring - an input stringpublic boolean execute(org.bukkit.entity.Player parser,
String string)
parser - a player to parse argumentsstring - an input stringpublic Pattern getPattern()
Pattern instance using the defined key and the
optional defined regex.
It always checks the start of a string and adds the
BeansLib.keysDelimiters on the start and end of the regex.
public static MessageExecutor fromFlag(MessageFlag flag)
@NotNull public static @NotNull MessageExecutor matchKey(String string)
CHAT_EXECUTOR.string - an input string@NotNull public static @NotNull MessageExecutor identifyKey(String s)
CHAT_EXECUTOR.s - an input stringpublic static void setDefaults()
Usefully for reload methods that depend on cache.
Copyright © 2023. All rights reserved.