-
Notifications
You must be signed in to change notification settings - Fork 0
API
The public integration surface is dev.stemcraft.api.STEMCraftAPI.
Static access to the STEMCraft API instance.
The instance becomes available after STEMCraft has enabled. Plugins should declare STEMCraft as a dependency or soft dependency before accessing it.
Returns
- the active API instance, or
nullbefore STEMCraft enables
Example:
`STEMCraftAPI api = STEMCraftAPI.api();`
STEMCraftAPI exposes the following runtime service families:
commands()coordinateBar()comets()config()audit()database()dialogs()events()holograms()items()locales()mailboxes()messages()minigames()motd()players()placedObjects()placeholders()protections()profanityFilter()punishments()playerStats()recipes()regions()selections()saves()tabComplete()tasks()web()worlds()
Extensions with pending in-memory state can join /stemcraft save and normal STEMCraft shutdown checkpoints:
Registering the same plugin and ID replaces the previous callback. Disabled plugins are discarded automatically. A callback must return only after its state is durable and may throw an exception; one failing participant is reported without preventing the remaining participants from saving. Call api.saves().unregister(myPlugin, "player-data") when an integration no longer owns that state.
api.saves().saveAll() invokes the same complete STEMCraft checkpoint as /stemcraft save. It covers active STEMCraft features and services, dirty STEMCraft configuration files, and enabled registered extensions. It deliberately does not save Bukkit worlds or vanilla player data.
Coordinates explicit save checkpoints for STEMCraft and its extensions.
Register or replace an extension save participant.
Parameters
-
owner— plugin which owns the pending state -
id— stable participant id, unique within the owning plugin -
participant— synchronous save callback
Example: Registering persistent extension state
api.saves().register(myPlugin, "player-data", () -> playerDataStore.flush());Remove a previously registered extension participant.
Parameters
-
owner— plugin which owns the participant -
id— participant ID used during registration
Save all STEMCraft features, services, configs, and enabled extension participants.
Returns
- report containing participant counts and failures
Whether a save checkpoint is currently running.
Returns
-
truewhile a checkpoint is active
CoordinateBarService lets extensions register ordered, player-specific Component providers for /coordbar. Providers return null when inactive. Registrations are keyed by owning plugin and ID, replace cleanly during reloads, and are discarded when their owning plugin is disabled. Extensions can also register amendments appended directly to the built-in world, time, or direction section. Amendments must supply their own spacing and are rendered without an automatic separator.
Extension point for adding contextual, live content to the coordinate boss bar.
Register or replace a provider owned by a plugin. Lower priority values render first. Registrations belonging to disabled plugins are discarded.
Remove one provider registration.
Register or replace content appended directly to a built-in section. No spacing or separator is inserted; the provider must include any desired whitespace.
Remove one built-in section amendment.
Render amendments for one built-in section in display order.
Render the currently active additions for a player in display order.
CometService launches destructive comet events at an impact location. Calls may use a random direction or supply a horizontal direction, with optional CometLoot block ranges scattered around the terminal geode. See Comets.
MailboxService queues letters and item stacks to a recipient UUID. MailSendRequest accepts either a player UUID or system string as its sender; player names are resolved internally. See Mailboxes for examples.
HologramService#createDynamic(...) registers location- or entity-anchored, player-specific holograms under a stable type/context key. Use refreshDynamic(...) after state changes and deleteDynamic(...) when the owning object is removed. The service manages Java/Bedrock rendering and world/chunk lifecycle.
ImageMapService creates wall-mounted filled-map mosaics and renders a BufferedImage across them. Callers use stable string IDs, can register per-display tile click callbacks, and do not manage the underlying maps or item frames.
DialogService exposes one fluent input-dialog builder backed by Paper dialogs on Java and Geyser Cumulus forms on Bedrock. Builders support body text, single- and multiline inputs, submit callbacks, and cancellation callbacks.
MessageService supports explicit MessageType and optional configured contexts. Trusted strings may begin with routing directives such as /survival//info/; player-authored chat is never directive-processed.
Rich custom item definitions include Java/Bedrock visual metadata and managed placement behavior. PlacedObjectService persists stable block/entity assemblies with role-labelled links.
The command API centers on:
CommandServiceCommandBuilderCommandCommandContextCommandExecutor
This is the preferred way to register new command surfaces inside STEMCraft and companion plugins.
All CommandContext positional argument accessors use zero-based indexes. getArgsAsString(index) joins arguments
starting at that same zero-based index, while getArgsAsString() joins the complete positional argument list.
The event layer wraps Bukkit listener registration through:
EventServiceEventHandler
This keeps event hookups lightweight and consistent with the rest of the plugin.
The world API includes:
WorldServiceWorldGenerationWorldBaseSettingWorldChangeSessionWorldSettingCommandWorldSettingCommandExecutor
This is the main extension point for:
- custom world settings
- generator registration
- world lifecycle tooling
- structured world mutation recording
The minigame API includes:
MiniGameServiceMiniGameMiniGameArenaMiniGameArenaHandlerMiniGamePlayerMiniGameTeamMiniGameTeamSelectionInputMiniGameTeamSelectionPolicyMiniGamePlaceholderProviderMiniGameHudProvider
Use these when extending or integrating with the arena framework.
Framework-managed team selection is now part of the public minigame API:
-
MiniGame#setTeamSelectionPolicy(...)declares the team-selection rules for a minigame. -
MiniGameArena#setLobbyRegion(...)stores the lobby area used by framework-owned lobby features. -
MiniGameArena#setTeamSelectionInput(...)enablesfloororhotbarselection for one arena.
At runtime the framework owns:
- floor and hotbar selection input handling
- provisional assignment for lobby/start phases
- countdown reset when the current lobby state no longer satisfies minimum-team rules
- shared placeholders such as
{player:selected-team}and{arena:lobby-team-line-1}
The minigame arena API also includes shared supply-drop helpers:
MiniGameArena#findRandomSupplyDropLocation(...)MiniGameArena#spawnSupplyDropCrate(...)MiniGameArena#clearAllSupplyDrops()
These are used by BedWars and Bridge to share the same crate/parachute drop presentation while leaving item selection and drop timing in the minigame handlers.
The minigame arena API also includes shared player-pull helpers:
MiniGameArena#pullPlayer(...)MiniGameArena#pullPlayers(...)MiniGameArena#cancelPlayerPulls()MiniGameArena#isPlayerBeingPulled(...)
These let minigames apply a straight-line pull toward one or more target locations at a specified blocks-per-second speed while the framework owns the per-tick movement and active-pull tracking.
The arena API also exposes lifecycle actions for entering and leaving a minigame:
MiniGameArena#getJoinCommands()MiniGameArena#setJoinCommands(...)MiniGameArena#getLeaveCommands()MiniGameArena#setLeaveCommands(...)MiniGameArena#getJoinPermissions()MiniGameArena#setJoinPermissions(...)
These actions fire when a player or spectator enters an arena from outside the minigame, and again when they fully leave it. Join permissions are attached for the duration of occupancy and are removed automatically on exit.
Lifecycle command tokens:
{player}{uuid}{arena}{arena-name}{minigame}{namespace}{role}
Lifecycle command execution rules:
-
server:runs the command as console -
player:runs the command as the player - no prefix also runs as the player
Example:
MiniGame game = api.minigames()
.create("examplegame", handler)
.setTeamSelectionPolicy(new MiniGameTeamSelectionPolicy() {
@Override
public List<MiniGameTeam> assignableTeams(MiniGameArena arena, Map<Player, String> preferences) {
return new ArrayList<>(arena.getTeams());
}
@Override
public int teamCapacity(MiniGameArena arena, MiniGameTeam team) {
return 2;
}
});
MiniGameArena arena = game.createArena("example", world)
.setLobbySpawn(world.getSpawnLocation())
.setLobbyRegion(selectionRegion)
.setTeamSelectionInput(MiniGameTeamSelectionInput.FLOOR);
arena.pullPlayer(player, arena.getLobbySpawn(), 50.0d);The protection API includes:
ProtectionServiceProtectionTypeProtectionRuleProtectionRequest
Use this when a feature wants to request a temporary gameplay protection while leaving the final allow/deny decision to shared policy rules.
The resource pack API includes:
ResourcePackServiceResourcePackGeneratorAbstractResourcePackGeneratorResourcePackBuildContextResourcePackBuildTargetResourcePackWriterResourcePackHost
This is the supported extension path for custom resource-pack generators.
The task API includes:
TaskServiceTaskCallbackTaskRetryableTaskRetryCallback
This is the preferred scheduling surface when work needs naming, delayed execution, retries, or persistence.
Useful supporting API types include:
SCRegionTokenProcessor- player stats records and definitions
- punishment records
- profanity filter result/severity
- prefer the interfaces in
api/over implementation classes inplugin/ - use locale keys and
messages()rather than hardcoded strings when integrating into the user-facing experience - keep persistent runtime data in SQLite through
database() - keep operator-authored configuration in YAML through
config()
- Home
- Architecture
- Services
- Features
- Build a Custom Tool
- Agriculture and Cooking
- Survival quality of life
- Custom items
- Slime and Magma Buckets
- Comets
- Rotten Flesh Uses
- Iron Golem Poppy Luring
- Gifts
- Mailboxes
- Notice boards
- Named regions
- Interactive guide callbacks
- Quests
- Commands
- API
- Minigames
- Minigame placeholders
- Tab completion
- Configuration
- Entitlements and badges
- Player reset service