Overview | EssentialsC | SpawnApi
net.godlycow.org.essc.api

Interface SpawnApi

public interface SpawnApi

API interface for interacting with EssentialsC's spawn system. Manages the server spawn location, teleportation with warmup and cooldown, and first-join spawning. All location data is persisted to spawn.yml.

Retrieve an instance via EssentialsCAPI.getSpawnApi().

SpawnApi spawn = APIProvider.getAPI().getSpawnApi();

if (spawn.isSpawnSet()) {
    spawn.teleportToSpawn(player);
}

Method Summary

boolean isSpawnSet()
Returns whether a spawn location has been set.
Location getSpawn()
Returns the current spawn location.
void setSpawn(Location location)
Sets the spawn location to the given location.
boolean isOnCooldown(Player player)
Returns whether the given player is currently on spawn cooldown.
long getRemainingCooldown(Player player)
Returns the remaining cooldown time in seconds for the given player.
boolean hasPendingTeleport(Player player)
Returns whether the given player has a pending spawn teleport warmup.
void teleportToSpawn(Player player)
Initiates teleportation to spawn for the given player.
void teleportToSpawnImmediate(Player player)
Immediately teleports the given player to spawn, bypassing warmup.
void cancelTeleport(Player player)
Cancels any pending spawn teleport for the given player.
void reload()
Reloads the spawn configuration from disk.
Method Detail
public boolean isSpawnSet()

Returns whether a spawn location has been set.

Returns:
booleantrue if spawn is configured and world is loaded
public Location getSpawn()

Returns the current spawn location.

Returns:
Locationa copy of the spawn location, or null if not set
public void setSpawn(Location location)

Sets the spawn location to the given location. Persists immediately to spawn.yml. Overwrites any existing spawn.

Warning: Must be called on the main thread.
Parameters:
locationthe location to set as spawn; must not be null
public boolean isOnCooldown(Player player)

Returns whether the given player is currently on spawn cooldown.

Players with the essentialsc.spawn.admin permission bypass cooldowns.

Parameters:
playerthe player to check; must not be null
Returns:
booleantrue if the player must wait before using spawn again
public long getRemainingCooldown(Player player)

Returns the remaining cooldown time in seconds for the given player.

Returns 0 if the player is not on cooldown or has bypass permission.

Parameters:
playerthe player to check; must not be null
Returns:
longremaining cooldown in seconds, or 0
public boolean hasPendingTeleport(Player player)

Returns whether the given player has a pending spawn teleport warmup.

Parameters:
playerthe player to check; must not be null
Returns:
booleantrue if a warmup is in progress
public void teleportToSpawn(Player player)

Initiates teleportation to spawn for the given player. Applies warmup and cooldown checks. Sends appropriate messages to the player. If warmup is configured, the teleport will occur after the delay unless cancelled.

Warning: Must be called on the main thread.
Parameters:
playerthe player to teleport; must not be null
public void teleportToSpawnImmediate(Player player)

Immediately teleports the given player to spawn, bypassing warmup. Cooldown is still applied unless the player has bypass permission.

Warning: Must be called on the main thread.
Parameters:
playerthe player to teleport; must not be null
public void cancelTeleport(Player player)

Cancels any pending spawn teleport for the given player. Has no effect if the player has no pending teleport.

Warning: Must be called on the main thread.
Parameters:
playerthe player whose teleport to cancel; must not be null
public void reload()

Reloads the spawn configuration from disk. Re-reads spawn.yml and updates the cached spawn location.

Warning: Must be called on the main thread.