Skip to content

Spawner Data Access

MethodDescriptionReturn Type
getSpawnerByLocation(Location)Gets spawner data by block locationSpawnerDataDTO
getSpawnerById(String)Gets spawner data by unique IDSpawnerDataDTO
getAllSpawners()Gets all registered spawnersList<SpawnerDataDTO>
getSpawnerModifier(String)Gets modifier to change spawner propertiesSpawnerDataModifier

The SpawnerDataDTO class provides read-only access to spawner information. To modify spawner properties, use SpawnerDataModifier:

MethodDescriptionReturn Type
getSpawnerId()Gets the unique spawner IDString
getLocation()Gets the spawner locationLocation
getEntityType()Gets the entity typeEntityType
getSpawnedItemMaterial()Gets spawned item material (for item spawners)Material
getStackSize()Gets current stack sizeint
getMaxStackSize()Gets maximum stack sizeint
getBaseMaxStoragePages()Gets base storage pagesint
getBaseMinMobs()Gets base minimum mobsint
getBaseMaxMobs()Gets base maximum mobsint
getBaseMaxStoredExp()Gets base maximum stored experienceint
getBaseSpawnerDelay()Gets base spawner delay in tickslong
isItemSpawner()Checks if this is an item spawnerboolean

The SpawnerDataModifier interface is the only way to modify spawner properties. It provides method chaining and requires calling applyChanges() to save modifications. Note: stackSize is read-only and cannot be modified:

MethodDescriptionReturn Type
getStackSize()Gets current stack size (read-only)int
getMaxStackSize()Gets maximum stack sizeint
setMaxStackSize(int)Sets maximum stack size (chainable)SpawnerDataModifier
getBaseMaxStoragePages()Gets base storage pagesint
setBaseMaxStoragePages(int)Sets base storage pages (chainable)SpawnerDataModifier
getBaseMinMobs()Gets base minimum mobsint
setBaseMinMobs(int)Sets base minimum mobs (chainable)SpawnerDataModifier
getBaseMaxMobs()Gets base maximum mobsint
setBaseMaxMobs(int)Sets base maximum mobs (chainable)SpawnerDataModifier
getBaseMaxStoredExp()Gets base maximum stored experienceint
setBaseMaxStoredExp(int)Sets base maximum stored experience (chainable)SpawnerDataModifier
getBaseSpawnerDelay()Gets base spawner delay in tickslong
setBaseSpawnerDelay(long)Sets base spawner delay in ticks (chainable)SpawnerDataModifier
applyChanges()Applies and recalculates all changesvoid

Gets spawner data by its block location.

import github.nighter.smartspawner.api.data.SpawnerDataDTO;
import org.bukkit.Location;
Location location = block.getLocation();
SpawnerDataDTO spawnerData = api.getSpawnerByLocation(location);
if (spawnerData != null) {
// READ-ONLY: Can only read data, cannot modify
player.sendMessage("Spawner ID: " + spawnerData.getSpawnerId());
player.sendMessage("Entity Type: " + spawnerData.getEntityType());
player.sendMessage("Stack Size: " + spawnerData.getStackSize());
player.sendMessage("Base Delay: " + spawnerData.getBaseSpawnerDelay() + " ticks");
// To modify values, use SpawnerDataModifier
SpawnerDataModifier modifier = api.getSpawnerModifier(spawnerData.getSpawnerId());
if (modifier != null) {
modifier.setBaseMaxMobs(10)
.setBaseMinMobs(2)
.setBaseSpawnerDelay(600L)
.applyChanges(); // Must call to save changes
player.sendMessage("Values updated!");
}
}

Gets spawner data by its unique identifier.

String spawnerId = "spawner-uuid-here";
SpawnerDataDTO spawnerData = api.getSpawnerById(spawnerId);
if (spawnerData != null) {
// READ-ONLY: Can only read data
Location location = spawnerData.getLocation();
player.sendMessage("Spawner location: " + location);
player.sendMessage("Max Stack: " + spawnerData.getMaxStackSize());
// To modify, use SpawnerDataModifier
SpawnerDataModifier modifier = api.getSpawnerModifier(spawnerId);
if (modifier != null) {
modifier.setMaxStackSize(2000)
.applyChanges();
player.sendMessage("Max stack size updated!");
}
}

Gets all registered spawners in the server.

import java.util.List;
List<SpawnerDataDTO> allSpawners = api.getAllSpawners();
player.sendMessage("Total spawners: " + allSpawners.size());
for (SpawnerDataDTO spawner : allSpawners) {
player.sendMessage("- " + spawner.getEntityType() +
" at " + spawner.getLocation() +
" (Stack: " + spawner.getStackSize() + ")");
}

Modifies spawner properties through the API with method chaining.

import github.nighter.smartspawner.api.data.SpawnerDataModifier;
// Get the spawner modifier
String spawnerId = "spawner-uuid-here";
SpawnerDataModifier modifier = api.getSpawnerModifier(spawnerId);
if (modifier != null) {
// Read current values
int currentStack = modifier.getStackSize(); // Read-only
long currentDelay = modifier.getBaseSpawnerDelay();
// Modify multiple values with method chaining
modifier.setBaseMaxMobs(15)
.setBaseMinMobs(5)
.setBaseSpawnerDelay(400L)
.setBaseMaxStoredExp(5000)
.setBaseMaxStoragePages(3)
.applyChanges(); // Must call to apply changes and recalculate
player.sendMessage("Spawner configuration updated!");
player.sendMessage("Note: Stack size cannot be modified (read-only)");
}

All base values can be both read and modified:

SpawnerDataModifier modifier = api.getSpawnerModifier(spawnerId);
if (modifier != null) {
// Read current values
int maxStoragePages = modifier.getBaseMaxStoragePages();
int minMobs = modifier.getBaseMinMobs();
int maxMobs = modifier.getBaseMaxMobs();
int maxStoredExp = modifier.getBaseMaxStoredExp();
long spawnerDelay = modifier.getBaseSpawnerDelay();
player.sendMessage("Current Config Values:");
player.sendMessage("Storage Pages: " + maxStoragePages);
player.sendMessage("Min Mobs: " + minMobs);
player.sendMessage("Max Mobs: " + maxMobs);
player.sendMessage("Max Exp: " + maxStoredExp);
player.sendMessage("Delay: " + spawnerDelay + " ticks");
// Modify values
modifier.setBaseMaxStoragePages(5)
.setBaseMinMobs(3)
.setBaseMaxMobs(20)
.setBaseMaxStoredExp(10000)
.setBaseSpawnerDelay(300L)
.applyChanges();
player.sendMessage("All values updated successfully!");
}



Last update: November 17, 2025 11:46:34