Skip to content

Explaination: MessageSystem

Ture Bentzin edited this page Dec 31, 2022 · 14 revisions

The MessageSystem

The MessageSystem in one of the build-in features delivered by the Core. This System allows you to access a central Database of Messages in various Languages and send them to the Players. You can use the MessageAPI to access the MessageSystem fron your Core / API. This MessageAPI allows you to get Access to the MiniMessages that can be displayed to the Player. To learn how to send a Message (classic way - Chat Message) please look at the "Introduction: API" Page.

How does the MessageSystem work?

The MessageSystem is powered by the SQL Database provided by the core. This Database is configured via the database.properties file located in the config folder of your master. The MessageSystem will create some tables in the given Database that are used for the management of replacements, messages, and locales. The primary Table is the "messages" Table that has one entry for every "MessageKey" and "locale" the message entered here will be displayed for the messageKey. The Locale is the Language of the Message, the core has the ability to detect the locale of the players automatically if you use the right MessageReciepents. If a specific Locale or Dialect is not available the System can fallback to the "next best" Language or if that is not available then the System will show the Message in the default "EN_US"

So to sum it up: The MessageSystem works by assigning MessageKeys and Locales to MiniMessages.

What is a MiniMesssage

The System uses the MiniMessage format to color and decorate the messages. If you want more information on how these Messages are formatted, then please look at the MiniMessage Documentation.

Replacers in the MessageSystem

The Core uses a custom System for the replacers that could be divided into two several systems. The first system uses MiniMessage tags and the other uses patterns.

The System that works with the Tags is controlled exclusively by the Database and is designed for permanent replacements over Messages. This could be colors, hovers, and of cause your prefix.

The MessageSystem that works with patterns is designed to insert data (like player names or values) within the process of sending a Message. A Pattern is built this way:{n} That means that the following patterns are valid: {0} {1} {3} {20} {305} And the following are not; {-3} {-0} {00} {03} {5,6} {da} {three} The replacers are "in order" which means that they start with 0 and go into positive numbers. If a replacer is not filled, it will be displayed as a pattern to the recipient.

MessageReciepent

The MessageSystem is compatible with multiple platforms which means that you cant send a Message to a Player or CommandSender directly. To send a Message to something you need to use a MessageRecipeint. The Paper and VelocityCore provide inbuild MessageReciepents to you.

Alternatively, you can use the getMessage(...) methods to get a Message as an Object. This gives you the opportunity to extract the MiniMessage as is and use it for different purposes than sending via chat. With this, you can display them in a Book or as a Name of an Item. But be aware that if the Message is once sent (or extracted), the language cant be changed. So if you translate an Item Name and the item is given to another player the Name will not change!

Clone this wiki locally