For all examples and more detailed explanation check out theWIKI.
Since all examples are on WIKI, I will give a small example of working with messages here.
In the resources folder create a "messages" folder, where also create several localization files. For example en.json and ru.json. The result is the following structure:
After running the plugin containing the main class, which was inherited from "DarkWaterJavaPlugin" - These files will appear in the plugin folder on the server.
Sending text from these files takes just two lines:
Code (Java):
publicfinalclass TestPlugin
extends DarkWaterJavaPlugin
{// Main class
@Override
publicvoid onStart
()throwsException{ // Code at startup }
privatevoid sendMessageToPlayer
(Player player
){ MessagesUtils messagesUtils
=new DarkMessagesUtils
(this); messagesUtils.
sendMessageWithPrefix(player, Message.
MESSAGE_HELLO);// We send to player the message "message_hello" from the json file. // This text will correspond to the selected localization of the player. } }
locale.default: en
# The default language if the player's language is not available on the server, or it has not been defined
first.join.message: true
# A message when the player enters, telling about the definition of the player's language and the possibility of changing this language. actionbar.indicators: true
# Indicators above the player's toolbar. This function is needed for some plugins that use DarkWaterAPI. Requires PlaceHolderAPI to work. config.version: 3
# DO NOT TOUCH THIS PLEASE =) debug: false
# This line is not in the config by default, but you can enter it in the DarkWaterAPI config to display config logs in the server console.