Developer APIs

General player data

We provide you with a class named /api/user/User.java that gives you general player data, including the list of friends, the list of blocked players, mailbox, and more… You can use 2 methods provided from public class FriendAPI to get the player data:

Optional<User> FriendAPI.findUser(UUID);
Optional<User> FriendAPI.findUser(OfflinePlayer);

List of friends

To get the list of all your friends:

List<Friend> getList();

List of online friends

To get the list of online friends:

List<Friend> getOnlineFriends();

List of blocked players

To get the list of blocked players:

BlockedList getBlockedList();

Blocking a player

To block a player you are hating:

void block(UUID target);

Unblocking a player

To unblock a player:

void unblock(UUID target);

Friend request

To send a friend request to a player:

void sendRequest(UUID target);

Find pending friend request

To find a friend request you received recently but are waiting for response:

Optional<Request> findWaitingRequest(UUID target, boolean checkExpire);

Add new friend

To immediately add a player to your friend list:

void addFriend(UUID target);

Unfriend a player

To remove a player from your friend list:

void unfriend(UUID target);

Allow the player’s friends to teleport to them

Before teleporting to your friend, you should check whether your friend allows you to teleport to them by using the method below:

boolean canTeleportTo();

To check whether your friend can teleport to you, use this method:

boolean canTeleport();

To allow/disallow your friend to teleport to you, use this method:

boolean setCanTeleport(boolean canTeleport);

Allow to receive mail from friends

boolean canMail(); // Checks whether the player can receive the mail of their friend or not.
void setCanMail(boolean canMail); // Sets whether the player can receive the mail of their friend or not.

Mailbox

This mailbox will contain all mails, including mails you have sent and mails you have received from your friends. It can be invoked from the User class:

Mailbox getMailbox();

Send new mail

To send a mail to your friend:

Mail mail = new MailImpl(UUID sender, UUID target, String content, ItemStack... items);
mail.send();

Attached items

To get attached items from a letter:

List<ItemStack> getAttachedItem();

Sender - revoke items from mail

There are 2 methods that allow you to revoke your items from the letter:

boolean revokeItem(ItemStack item); // Revoke the specified item.
boolean revokeAllItems(); // Revoke all items contained in the letter.

Receiver - take items from mail

Same as revoke items, there are 2 methods that allow you to take items from the letter:

boolean takeItem(ItemStack item); // Take the specified item.
boolean takeAllItems(); // Take all items contained in the letter.

Events

We also provide you with some event classes, see details at: Events API.