5 Developer API
Ryandw11 edited this page 2020-06-26 20:17:46 -07:00

UltraChat API

Starting off

To start you need to put this:

UltraChatAPI chat = new UltraChatAPI();

This will allow you to access the API features.

Events

A Note on AsyncPlayerChatEvent

The plugin has the highest event priority on all 3 chat types. (In Bukkit highest priority means that the code is ran last, confusing, I know).
The plugin removes all of the recipients and does not cancel the event itself.
As long as you do not edit the formatting or require UltraChat specific api then this event will work perfectly for the Normal and Channel chat types.
This event will only fire if the local chat is used when in Range mode.
To add compatibility for World and Local chat in range mode you need to use the UltraChatEvent.

UltraChatEvent

The Ultra Chat Event is an event that is called when ever someone chats using the any of the 3 chat types (Normal, Range, Channel).

@EventHandler
public void onChat(UltraChatEvent event) {
}

Check out the methods for UltraChatEvent here(In me.ryandw11.api.events package)
One of the unique things about the event is the properties. The properties contain information about the unique type at hand.
For example to get the channel the player is chatting in you can do this:

@EventHandler
public void onChat(UltraChatEvent event) {
    if(event.getType() != ChatType.CHANNEL) return;
    ChannelProperties prop = (ChannelProperties) event.getProperties();
    System.out.println(prop.getChannel().getName());
}

Player Formatting

This is a handy class to have when trying to get information about the player. Example:

PlayerFormatting pf = new PlayerFormatting(player);
pf.getPrefix();
pf.getSuffix();
pf.getOpFormat(); //Already translates placeholder api stuff
pf.getColor();