๐ฌ Player Messages โ
MythicLib provides unified syntax for messages sent to players by all MMO plugins.
Most MMO plugins have a messages.yml config file where you can edit messages sent by the plugin. Below is part of the MMOCore/messages.yml config file
level-up:
sound: ENTITY_PLAYER_LEVELUP,1,2
# Runs a script on level up. This script is implemented
# inside file MythicLib/scripts/mmocore_scripts.yml
script: mmocore_level_up_effect
message:
- ''
- '&eCongratulations, you reached level &6{level}&e!'
- '&eUse &6/p &eto see your new statistics!'
- ''
#......
exp-notification:
message: '&f{profession} &e{progress} &e{ratio}%'
action-bar: true
#sound: ENTITY_EXPERIENCE_ORB_PICKUP # Not recommended, can be spammy
death-exp-loss:
- ''
- '&4You died and lost {loss} experience.'
- ''
#......
already-on-class: '&cYou are already a {class}.'In the next sections, we will take the example of the MMOCore message sent when a player levels up their main class (level-up) but this is applicable to any message from any MMO plugin.
Basic Syntax โ
This sends one line of text to the player chat.
level-up:
format: '&eCongratulations, you reached level &6{level}&e!'This sends multiple lines of text to the player chat. As you can see, format can either be text or a list of texts.
level-up:
format:
- '&eCongratulations, you reached level &6{level}&e!'
- '&eUse &6/p &eto see your new statistics!'Send to action bar โ
If you want to send the message to the player's action bar instead, set action-bar to true.
level-up:
format: #........
action-bar: trueExtra options โ
In MythicLib, the action bar is shared by all MMO plugins. To avoid action bar messages messing with other features from other plugins utilizing the action bar, we implemented a message priority & timeout system. This priority system is not needed for chat messages because messages don't "hide" or collide with one another.
Every message has a priority and a duration, which are both positive integers. One-time messages (such as level-up or waypoint use messages) usually have high priority, and passive messages like MMOCore player info action bars usually have low priorities.
When multiple messages are sent simultaneously to the same player, only the message with highest priority will show on the player's action bar. The high-priority message will temporarily "hide" the message with low priority, for a set period of time (the message duration).
The message priority and duration can be edited using the following syntax
level-up:
format: #........
action-bar: true # Has to be on
priority: 30 # Message priority
duration: 50 # In ticks, 2.5 secondsThe MMOCore player information action bar runs on priority LOW, set to 20. The MMOCore skill casting action bars run on priority NORMAL set to 30.
Play a sound โ
Sounds can be played when the message is sent to the player. The basic syntax is <SOUND_NAME>,<pitch>,<volume>. <SOUND_NAME> can either be a Bukkit sound name, the list of which you can find in the Spigot javadocs, or the name of a custom sound (provided by a resource pack for instance), like itemsadder:sound_id. If you want to use a pitch and volume of 1, <SOUND_NAME> works just as well.
level-up:
format: #......
sound: 'ENTITY_PLAYER_LEVELUP,1,1' # Or simply 'ENTITY_PLAYER_LEVELUP'The following syntax does the same thing
level-up:
format: #.....
sound:
sound: ENTITY_PLAYER_LEVELUP
vol: 1
pitch: 1You can even remove the format field and only send a sound to the player, with no text sent to the player chat or action bar.
Call a MythicLib script โ
You can run a MythicLib script when a message is sent to a player. For instance, MythicLib comes with a script named mmocore_level_up_effect which displays a small particle effect around the player. By default, it is called when the player levels up either their main class or a profession.
level-up:
format: #......
sound: #......
script: 'mmocore_level_up_effect'This is the code of the mmocore_level_up_effect script, which can be found in the MythicLib/script/mmocore_scripts.yml file.
# Script ran when leveling up
# Displays a helix of particles around the player
# This is configured in MMOCore/messages.yml > level-up.script
mmocore_level_up_effect:
mechanics:
- "helix{tick=mmocore_level_up_effect_tick;radius=1;height=2}"
mmocore_level_up_effect_tick:
mechanics:
- "spawn_particle{particle=TOTEM}"