xSpawnxSpawn

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
  • void setFirstSpawn(Location location)

    Sets the first spawn location.
XSpawnAPI.setFirstSpawn(new Location(world, x, y, z));
  • Location getFirstSpawn()

    Gets the first spawn location.
Location first = XSpawnAPI.getFirstSpawn();
  • void removeFirstSpawn()

    Deletes the first spawn location.
XSpawnAPI.removeFirstSpawn();
  • void setPlayerSpawn(String playerName, Location location)

    Sets a specific spawn for a player.
XSpawnAPI.setPlayerSpawn("Steve", location);
  • Location getPlayerSpawn(String playerName)

    Gets a player's specific spawn.
Location spawn = XSpawnAPI.getPlayerSpawn("Steve");
  • void removePlayerSpawn(String playerName)

    Removes a player's specific spawn.
XSpawnAPI.removePlayerSpawn("Steve");
  • void setTeamSpawn(Team team, Location location)

    Sets a spawn location for a specific team.
XSpawnAPI.setTeamSpawn(team, location);
  • Location getTeamSpawn(Team team)

    Gets a team's spawn location.
Location spawn = XSpawnAPI.getTeamSpawn(team);
  • void removeTeamSpawn(Team team)

    Removes a team's spawn location.
XSpawnAPI.removeTeamSpawn(team);
  • Location getSpawnFor(Player player)

    Returns the best spawn for a player (player > team > first spawn > world spawn).
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.
  • FallbacksgetSpawnFor handles proper fallbacks: player spawn → team spawn → first spawn → world spawn.

🔗 References