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:
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:
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:
To modify the player's kills statistic:
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:
To add 50 coins to an offline player's balance:
Checking Player Status
The Skywars API provides several methods for checking a player's current status in the game.
SkywarsAPI.isInArena(Player player)
returnstrue
if the player is currently in an arena, andfalse
otherwise.SkywarsAPI.isSpectating(Player player)
returnstrue
if the player is currently spectating a game, andfalse
otherwise.SkywarsAPI.isPlaying(Player player)
returnstrue
if the player is currently playing a game, andfalse
otherwise.
Last updated