-
Notifications
You must be signed in to change notification settings - Fork 0
Using the CommunicatorAPI
CommunicatorAPI is a way to send messages to players in an object-oriented style. CommunicatorAPI works on the principle of layering a message before sending it to the player, starting at the top (Communicator) and ending with a potentially infinite tree of placeholders and different message types.
The Communicator asks for a JSON message to be sent to the player, and for that it gives the nickname of the player to the message requested. The message object, depending on what kind of message it is, thinks where to get that JSON and gives it to the player.
The possibilities for creating logic with this approach are endless - for example, a message can have internal placeholders-messages that can be given a player nickname, and they can also have their own internal messages, and so on to the limits of your imagination.
The basic CommunicatorAPI message is Message. Message takes plain text as input, and converts it into JSON to be sent to the player. It understands &a colors, minimessage, and \n line separations, and sets the placeholders you passed to it. The placeholder can be any object that knows how to convert strings into JSON using the player's name, including Message itself, as well as LAPIMessage, which will be mentioned in the Using LanguageAPI article.
Here's an example how to use CommunicatorAPI (the real example from QiwiPay plugin)
new Communicator(this.receiver).send(new LAPIMessage(
AncapPay.class, "bill.pay-url",
new Placeholder("click", new Message(
"<click:open_url:%URL%>%URL_CLICK_MESSAGE%</click>",
new Placeholder("url", payUrl),
new Placeholder("url_click_message", new LAPIMessage(AncapPay.class, "bill.pay-url-click")
))
));-
Создание плагина
- Создание main-класса
- Настройка ancapplugin.yml
- Использование AncapPluginAPI
- Использование LanguageAPI
- Использование CommunicatorAPI
- Использование ConfigurationAPI
- Использование CommandAPI
- Использование DatabaseAPI
- Использование EventAPI
- Использование MaterialAPI
- Использование WorldIteratorAPI
- Использование BukkitUtil
- Использование ResourceAPI
-
- Creating main class
- Setting up the ancapplugin.yml
- Using the AncapPluginAPI
- Using the LanguageAPI
- Using the CommunicatorAPI
- Using the ConfigurationAPI
- Using the CommandAPI
- Using the DatabaseAPI
- Using the EventAPI
- Using the MaterialAPI
- Using the WorldIteratorAPI
- Using the BukkitUtil
- Using the ResouceAPI