# API

## Skywars API Documentation

The Skywars API is a set of tools and methods provided by the Skywars plugin to allow developers to access and modify player data and statistics in their own plugins.

### Getting Started

To use the Skywars API in your plugin, you will need to include the following import statement:

```java
import me.wazup.skywars.SkywarsAPI;
```

You will also need to ensure that the Skywars plugin is installed and running on your server.

### Accessing Player Data

To access a player's data, use the `SkywarsAPI.getPlayerData(Player player)` method, which returns a `PlayerData` object containing various statistics and information about the player.

For example:

```java
Player p = Bukkit.getPlayer("Wazup92");
PlayerData data = SkywarsAPI.getPlayerData(p);
```

You can then access and modify the player's data using the various methods and properties of the `PlayerData` object. For example, to add 50 coins to the player's balance:

```java
data.addCoins(p, 50);
```

To modify the player's kills statistic:

```java
data.kills += 10;
```

### Modifying Offline Player Data

To modify the data of an offline player, you can use the `SkywarsAPI.modifyOfflinePlayerStat(String playerName, Stat stat, int value, boolean increment)` method. This method allows you to set or modify a specific statistic for an offline player.

The `playerName` parameter should be the name of the player as it appears in the database. The `stat` parameter should be one of the `Stat` enum values, representing the statistic you want to modify. The `value` parameter is the value you want to set or add to the statistic, and the `increment` parameter determines whether you want to set the statistic to the given value (`false`) or add the value to the current statistic (`true`).

For example, to set an offline player's coins to 50:

```java
try {
  boolean updated = SkywarsAPI.modifyOfflinePlayerStat("Wazup92", Stat.COINS, 50, false);
} catch (SQLException e){
  e.printStackTrace();
}
```

To add 50 coins to an offline player's balance:

```java
try {
  boolean updated = SkywarsAPI.modifyOfflinePlayerStat("Wazup92", Stat.COINS, 50, true);
} catch (SQLException e){
  e.printStackTrace();
}
```

### Checking Player Status

The Skywars API provides several methods for checking a player's current status in the game.

* `SkywarsAPI.isInArena(Player player)` returns `true` if the player is currently in an arena, and `false` otherwise.
* `SkywarsAPI.isSpectating(Player player)` returns `true` if the player is currently spectating a game, and `false` otherwise.
* `SkywarsAPI.isPlaying(Player player)` returns `true` if the player is currently playing a game, and `false` otherwise.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://swdocs.juriantech.nl/api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
