---
description: >-
  The plugin offers a complete developer Spigot API, which allows other plugins
  on the server to manage friends, parties, settings and much more.
---

# Developer API

To use the API, simply add the 'FriendSystem-Spigot-API.jar' to your project.

You also need to put the FriendSystem-Spigot-API.jar in your plugins folder of your minecraft server and enter your MySQL data in the database.yml file. \
The MySQL credentials must be the same, as on the bungeecord / velocity server.&#x20;

{% file src="https://1569454400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7hZ32tFABZCR9Mu1qusJ%2Fuploads%2Fgk3yNDaaaE5edSyXxfpO%2FFriendSystem-Spigot-API-1.0.zip?alt=media&token=6d801a1b-62e2-4b43-82c1-2f71b6aebd99" %}
FriendSystem-Spigot-API
{% endfile %}

You can then access the API through&#x20;

```java
SpigotAPI api = SpigotAPI.getInstance();
```



## FriendManager

The `FriendManager` provides functionality related to managing friends and their interactions.\
You can retrieve the `FriendManager`by using:

```java
FriendManager friendManager = api.getFriendManager();
```



**You can use the `FriendManager` for the following:**

{% code title="Retrieve a FriendPlayer from MySQL async" %}
```java
void getFriendPlayer(UUID uuid, Consumer<FriendPlayer> friendPlayer);
```
{% endcode %}

{% code title="Retrieve a FriendPlayer from MySQL async" %}
```java
void getFriendPlayer(String name, Consumer<FriendPlayer> friendPlayer);
```
{% endcode %}

{% code title="Retrieve a FriendPlayer from MySQL" %}
```java
FriendPlayer getFriendPlayer(UUID uuid);
```
{% endcode %}

{% code title="Retrieve a FriendPlayer from MySQL" %}
```java
FriendPlayer getFriendPlayer(String name);
```
{% endcode %}

{% code title="Toggle friend invites " %}
```java
void toggleInvites(FriendPlayer player);
```
{% endcode %}

{% code title="Toggle private messages" %}
```java
void toggleMsgs(FriendPlayer player);
```
{% endcode %}

{% code title="Toggle join/leave notifications" %}
```java
void toggleNotifies(FriendPlayer player);
```
{% endcode %}

{% code title="Toggle the option allowing a player to be "jumped to"" %}
```java
void toggleJumping(FriendPlayer player);
```
{% endcode %}

{% code title="Toggle the last seen / online since visibility" %}
```java
void toggleLastSeen(FriendPlayer player);
```
{% endcode %}

{% code title="Toggle server visibility" %}
```java
void toggleShowServer(FriendPlayer player);
```
{% endcode %}

{% code title="Toggle party invites" %}
```java
void togglePartyInvites(FriendPlayer player);
```
{% endcode %}

{% code title="Update the status message" %}
```java
updateStatus(FriendPlayer player, String status);
```
{% endcode %}

{% code title="Send a friend request" %}
```java
addFriendRequest(Player sender, UUID receiver);
```
{% endcode %}

{% code title="Accept a friend request " %}
```java
acceptFriendRequest(Player sender, UUID receiver);
```
{% endcode %}

{% code title="Deny friend request" %}
```java
denyFriendRequest(Player denier, UUID requester);
```
{% endcode %}

{% code title="Remove a friend" %}
```java
removeFriend(Player remover, UUID removed);
```
{% endcode %}

{% code title="Mark/unmark a friend as favourite" %}
```java
toggleFavouriteFriend(Player sender, UUID favourite);
```
{% endcode %}



## FriendPlayer

The `FriendPlayer` represents a player within the Friend System.\
You can retrieve the following informations from a `FriendPlayer`

{% code title="Retrieve name of the player" %}
```java
String getName();
```
{% endcode %}

{% code title="Check if the player allows friend invites" %}
```java
boolean isInvitesAllowed();
```
{% endcode %}

{% code title="Get Messages State. States are ENABLED, DISABLED and FRIENDS_ONLY" %}
```java
boolean getMsgsState();
```
{% endcode %}

{% code title="Check if the player jumping to their server" %}
```java
boolean isJumpingAllowed();
```
{% endcode %}

{% code title="Check if last seen / online since is visible" %}
```java
boolean isShowLastSeen();
```
{% endcode %}

{% code title="Check if server is visible" %}
```java
boolean isShowServer();
```
{% endcode %}

{% code title="Get Party Invites State. States are ENABLED, DISABLED and FRIENDS_ONLY" %}
```java
SettingState getPartyInvitesState();
```
{% endcode %}

{% code title="Get the last date when the player logged in or out" %}
```java
LocalDateTime getLastSeen();
```
{% endcode %}

{% code title="Retrieves the current status of the player" %}
```java
String getStatus();
```
{% endcode %}

{% code title="Retrieves the list of all friends. The boolean indicates if the friend is marked as favourite" %}
```java
HashMap<String, Boolean> getFriends();
```
{% endcode %}

{% code title="Retrieves the list of online friends. The boolean indicates if the friend is marked as favourite" %}
```java
HashMap<ProxiedPlayer, Boolean> getOnlineFriends();
```
{% endcode %}

{% code title="Retrieves the list of offline friends. The boolean indicates if the player is marked as favourite" %}
```java
HashMap<String, Boolean> getOfflineFriends();
```
{% endcode %}

{% code title="Check if the friend player is friends with another player" %}
```java
boolean isFriendsWith(String uuid);
```
{% endcode %}

{% code title="Check if the friend player has received a friend request from a player " %}
```java
boolean isRequestedBy(String uuid);
```
{% endcode %}

{% code title="Retrieves the list of all pending friend requests" %}
```java
ArrayList<String> getRequests();
```
{% endcode %}



## PartyManager

The `PartyManager` provides functionality related to managing or retrieving parties.

{% code title="Get instance of PartyManager" %}
```java
PartyManager partyManager = api.getPartyManager();
```
{% endcode %}

\
**You can use the PartyManager for the following:**

{% code title="Retrieve a Party from MySQL async" %}
```java
void getParty(UUID player, Consumer<Party> party);
```
{% endcode %}

{% code title="Retrieve a Party from MySQL" %}
```java
Party getParty(UUID player);
```
{% endcode %}

{% code title="Get a List of all Parties from MySQL async" %}
```java
void getAllParties(Consumer<List<Party>> parties);
```
{% endcode %}

{% code title="Get a List of all Parties from MySQL" %}
```java
List<Party> getAllParties();
```
{% endcode %}

{% code title="Create a party" %}
```java
void createParty(Player leader, String... memberUUIDs)
```
{% endcode %}

{% code title="Close a party" %}
```java
void disbandParty(Player leader);
```
{% endcode %}

{% code title="Invite a player to a party" %}
```java
void invitePlayer(UUID leader, Player player);
```
{% endcode %}

{% code title="Remove a party invite" %}
```java
void removeInvite(UUID leader, Player player);
```
{% endcode %}

{% code title="add a player to a party" %}
```java
addPlayer(UUID leader, Player player);
```
{% endcode %}

{% code title="kick a player from a party" %}
```java
kickPlayer(UUID leader, Player player);
```
{% endcode %}

{% code title="promote a player to the next rank in a party" %}
```java
promotePlayer(UUID leader, Player player);
```
{% endcode %}

{% code title="demote a player to the next rank in a party" %}
```java
demotePlayer(UUID leader, Player player);
```
{% endcode %}



## Party

The `Party`represents a party within the Friend System.\
You can retrieve the following informations from a `Party`

{% code title="Get the id of the party" %}
```java
int getPartyId();
```
{% endcode %}

{% code title="Get the leader UUID" %}
```java
UUID getLeaderUUID();
```
{% endcode %}

{% code title="Get a list of the members (only players)" %}
```java
List<UUID> getMemberUUIDs();
```
{% endcode %}

{% code title="get a list of all members (leader, moderators, players)" %}
```java
List<UUID> getAllMembers();
```
{% endcode %}

