xSpawn API 🛠️
📄 Introduction
The xSpawnAPI provides static methods to interact programmatically with xSpawn. You can manage spawns for players, teams, and the first spawn directly from your code without creating an instance or initializing anything manually.
🛠 Installation
Add the repository and dependency for xSpawn.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.xDrygo</groupId>
<artifactId>xSpawn</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>After adding the dependency, add xSpawn as a dependency in your plugin.yml:
name: MyPlugin
main: com.example.MyPlugin.MyPlugin
version: 1.0
depend: # use depend if API is required, soft-depend if optional
- xSpawn📋 XSpawnAPI Methods
Click to expand
Sets the first spawn location.void setFirstSpawn(Location location)
XSpawnAPI.setFirstSpawn(new Location(world, x, y, z));
Gets the first spawn location.Location getFirstSpawn()
Location first = XSpawnAPI.getFirstSpawn();
Deletes the first spawn location.void removeFirstSpawn()
XSpawnAPI.removeFirstSpawn();
Sets a specific spawn for a player.void setPlayerSpawn(String playerName, Location location)
XSpawnAPI.setPlayerSpawn("Steve", location);
Gets a player's specific spawn.Location getPlayerSpawn(String playerName)
Location spawn = XSpawnAPI.getPlayerSpawn("Steve");
Removes a player's specific spawn.void removePlayerSpawn(String playerName)
XSpawnAPI.removePlayerSpawn("Steve");
Sets a spawn location for a specific team.void setTeamSpawn(Team team, Location location)
XSpawnAPI.setTeamSpawn(team, location);
Gets a team's spawn location.Location getTeamSpawn(Team team)
Location spawn = XSpawnAPI.getTeamSpawn(team);
Removes a team's spawn location.void removeTeamSpawn(Team team)
XSpawnAPI.removeTeamSpawn(team);
Returns the best spawn for a player (player > team > first spawn > world spawn).Location getSpawnFor(Player player)
Location spawn = XSpawnAPI.getSpawnFor(player);💡 Notes
- No initialization required – The API is automatically initialized by the plugin.
- Static methods – All methods are static, so you can call them directly.
- Team support – Requires xTeams for team-based spawns.
- Fallbacks –
getSpawnForhandles proper fallbacks: player spawn → team spawn → first spawn → world spawn.