Sueta

SpigotMessageAPI

v1.1.0

Give your plugin users a better experience with this user-friendly message setup API.

·Plugin

SpigotMessageAPI.png

Please report any bugs you found here.
Sounds are different for 1.8/1.10! (Download Sounds 1.8) (Download Sounds 1.10)

rsz_github.jpg

Features.jpg

  • Give server owners the best experience while setting up messages for your plugin.
  • 1.8-1.12 Title Support
  • 1.8-1.12 Actionbar Support
  • Message (One line)
  • Message List (Multiple Lines)
  • Sound Support
  • Use multiple options. (Ex: Title & Actionbar)
  • Use only specific options. (Ex: only Title)
  • Use your own variables.
  • User-friendly
How To: Messages

Players will be able to configure their messages like explained below. You can use multiple options (for example, you are able to send a regular message and an actionbar!) This is the format of these messages, an example usage will be given below.

<config-path>:
  Message: '<message>'
  MessageList:
  - '<message1>'
  - '<message2>'
  Title:
    FadeIn: <fade in time>
    Stay: <stay time>
    FadeOut: <fade out time>
    Title: '<message>'
    Subtitle: '<message>'
  ActionBar:
    Stay: <stay time>
    ActionBar: '<message>'
  Sound: <sound>

The format will change when a specific load type is used. It will replace the "Message", "MessageList", "Title", "ActionBar" and "Sound" with the config path:

<config-path>: '<message>'
<config-path>:
  - '<message1>'
  - '<message2>'
<config-path>:
  FadeIn: <fade in time>
  Stay: <stay time>
  FadeOut: <fade out time>
  Title: '<message>'
  Subtitle: '<message>'
<config-path>:
  Stay: <stay time>
  ActionBar: '<message>'
<config-path>: <sound>

Regular Message:

ToReceiver:
  Message: '&7[%server-sender%&7] &6%suggest-player% &7> &7[%server-receiver%&7] &6%receiver%&7: &6%msg%'

Multiple Messages:

ToReceiver:
  MessageList:
  - '&7[%server-sender%&7] &6%suggest-player% &7sent you a message:
  - '&6%msg%'

Title:

ToReceiver:
  Title:
    FadeIn: 2
    Stay: 10
    FadeOut: 2
    Title: '&7%sender%'
    Subtitle: '&6%msg%'

ActionBar:

ToReceiver:
  ActionBar:
    Stay: 10
    ActionBar: '&6%sender%&7: &6%msg%'

Sound:

ToReceiver:
  Sound: <sound>
How To: Use SpigotMessagesAPI

There are several things you'll have to do in order to use SpigotMessagesAPI. (Players will also have to install this plugin on their server)

Step 1:
Set " depends: [SpigotMessagesAPI]" in your plugin.yml

Step 2:
Import SpigotMessagesAPI to your project, different for each software you use. This option will most likely be called "library".

Step 3:
Register one of your config files.

SpigotMessageAPI.registerConfigFile(<name>, new ConfigFile(<directory>, <file name>));

Here is an example usage:

ConfigFile configFile = new ConfigFile(getDataFolder().getPath(), "config.yml");
SpigotMessageAPI.registerConfigFile("config", configFile);

Step 4:
Register messages:

SpigotMessageAPI.registerMessage(<name>, new Message(<config file>, <path>));

You can also put a load type in that method, that way it will only load that method:

SpigotMessageAPI.registerMessage(<name>, new Message(<config file>, <path>, LoadType.TITLE));

Here is an example usage:

SpigotMessageAPI.registerMessage("msg", new Message(configFile, "Messages.MSG"));

Step 5:
Use the plugin. Here are a few methods that you'll be able to use with SpigotMessageAPI.

//Getter for config file
ConfigFile configFile = SpigotMessageAPI.getConfigFile(String name)
//Reload config file (with all messages setup for it)
configFile.reload();

//Getter for message
Message message = SpigotMessageAPI.getMessage(String name)
//Get message parser, to replace variables etc.
MessageParser mP = message.getParser();
//Replace variables
mP.parseVariable(String variable, String replacement)
//Send message
mP.send(CommandSender sender);
//Send message as long as it doesn't contain x, y, z... (Will be done per line if a list, the same for title and subtitle)
mP.send(CommandSender sender, String... cannotContain);

If you found any sorts of bugs or do you have any suggestions, please, put them in the comments so I'll be able to make this plugin better!

If you want to support my projects with a donation:

Similar projects

Plugin →