Custom Variables
Ultimate control of variables.
Custom variables offer a flexible way to enhance chat and message customization within the AdvancedChat plugin. These variables can dynamically display content based on the player's context, the server state, or other criteria, using JavaScript expressions for their values. They can be utilized in chat messages or within the plugin's messaging system for various creative applications.
Configuration Example: variables/item.yml
variables/item.yml
Key Elements Explained
type: Determines how the variable is used.
CHAT_MESSAGE
means the variable will be encapsulated in brackets[]
when used in chat messages. If it's aPLACEHOLDER
, it will be encapsulated in percentage symbols%%
(e.g.,%item%
).name: The identifier for the variable, which will be used within tags in messages (e.g.,
[item]
or%item%
for placeholders).value: Defines the value of the variable using JavaScript. It can interact with the Minecraft server API, access player information, and even perform operations or transformations on data. In this example, it concatenates the quantity and capitalized name of the item the player is holding.
Accessible objects include the
player
instance, allowing you to fetch information such as the player's name (player.getName()
) or the item they are holding (player.getItemInHand()
).The
plugin
variable gives access to server-wide information, such as the total number of online players (plugin.getServer().getOnlinePlayers().size()
).The
event
variable allows interaction with event-specific data, useful when the variable is linked to specific events like chat messages (AsyncPlayerChatEvent
).
hover: Configures a hover effect for the variable. This can be plain text, an item stack (showing the item's details on hover), or an entity. In the provided example, hovering over the variable in chat will show the item the player is holding.
Implementation and Uses
Chat Customization: Enhance player chat messages by incorporating dynamic information like current held items, player stats, or server events.
Messaging System: Use custom variables in automated messages, announcements, or commands within the AdvancedChat plugin to provide personalized information.
Interactive Content: Combine custom variables with hover texts or actions (like clickable links) to create interactive chat experiences.
Last updated