Developer API
Command/paste stopSince 1.6.0 other plugins can put a player in IgnitePaste's paste mode with any schematic file on disk, restrict where it may land, handle the payment themselves and hear back when it is placed or cancelled. IgniteSky's template gallery is built on it.
Getting the API
APIIgnitePasteThe API is registered in Bukkit's services manager. Depend on the IgnitePaste jar at compile time (the project's build publishes com.ignitedev:IgnitePaste:1.6.2 with publishToMavenLocal) and add IgnitePaste to depend or softdepend.
IgnitePasteAPI api = IgnitePasteAPI.get(); // null while IgnitePaste is not enabled| Method | Returns |
|---|---|
startExternalPaste(Player, ExternalPasteRequest) | Optional<ExternalPasteSession>. Empty when the player is already in paste mode or has a construction running, or the file cannot be read. Main thread only |
isBusy(Player) | Whether the player is in paste mode, has a construction running or a paste still landing |
pastesBlockData() | Whether a paste carries block entity data (chest contents, sign text). Always true since 1.6.1; on 1.6.0 only the plain WorldEdit path did |
pastesEntities() | Whether a paste started now places the schematic's entities (paste.copy-entities) |
Use the last two to charge for exactly what the paste will hand out. Since 1.6.1 containers arrive full on every path, so their contents are worth charging for.
Starting a paste
IgnitePasteAPI api = IgnitePasteAPI.get();
Optional<ExternalPasteSession> session = api.startExternalPaste(player, ExternalPasteRequest.builder()
.schematic(new File(getDataFolder(), "templates/starter.schem"))
.displayName("<green>Starter Base")
.area((world, box) -> myRegion.contains(world, box))
.costHandledExternally(true)
.listener(new ExternalPasteListener() {
@Override
public CompletableFuture<Void> beforePlace(World world, BoundingBox box) {
return takeSnapshot(world, box);
}
@Override
public void placed(World world, BoundingBox box) {
markTemplateUsed(player);
}
@Override
public void cancelled(PasteEndReason reason, boolean blocksChanged) {
refund(player);
}
})
.build());The player enters one-time paste mode with the schematic selected and sees Place <name> with the tools, then paste it once. The file can live anywhere; it is indexed as a hidden entry for this player only and removed when the session ends. A sidecar .yml next to the file is read like any other, so it can set a construction-duration.
ExternalPasteRequest
| Field | Default | Meaning |
|---|---|---|
schematic | required | The .schem or .schematic file |
displayName | the sidecar's display-name | MiniMessage name shown in chat and on the boss bar. Set one: without it players see the internal entry name, @external/<file>/<uuid> |
area | PasteArea.ANYWHERE | Where it may land. Checked with the final bounding box when the player pastes |
costHandledExternally | true | Skip IgnitePaste's money, material cost, cooldown, use limit, building limit and stats. false makes it a normal priced paste |
listener | no-op | Callbacks, below |
Permissionignitepaste.schemPasteArea is a functional interface, boolean allows(World world, BoundingBox box), with block coordinates and an exclusive max corner. A paste outside it is refused with external-out-of-bounds and the session stays open. The normal land checks (WorldGuard, PlotSquared, Towny, IgniteSky) run as well. Permission gating does not: the entry is hidden, like a blueprint, so the player needs no ignitepaste.schem node for it. An allowed-worlds list in the file's sidecar still applies.
ExternalPasteListener
All callbacks run on the main thread. A session ends with exactly one of placed or cancelled.
| Callback | When |
|---|---|
beforePlace(World, BoundingBox) | The player committed, before the first block changes. The paste waits for the returned future; a failed future aborts the placement with Paste failed: <reason> and leaves the session open. Take snapshots here |
placed(World, BoundingBox) | The paste finished, construction included |
cancelled(PasteEndReason, boolean blocksChanged) | The session ended without a finished paste. Runs after the player's inventory is back, and after a running construction was rolled back when blocksChanged is true |
While beforePlace runs, another click on the paste wand gives Hold on, the paste is being prepared.
PasteEndReason | Cause |
|---|---|
CLOSED | The player used the close item or /paste stop |
DISCONNECTED | The player logged out |
CANCELLED | Your plugin called ExternalPasteSession.cancel() |
FAILED | The paste threw an error after committing |
SHUTDOWN | IgnitePaste was disabled |
Config keyconstruction.rollback-on-cancelA construction cancelled on an external paste is always rolled back, whatever construction.rollback-on-cancel says, because the caller is expected to refund it. On shutdown every running paste is rolled back first, external or not, and the caller hears cancelled(SHUTDOWN, true); that includes an async paste still landing after the player left paste mode.
ExternalPasteSession
| Method | Meaning |
|---|---|
playerId() | The player |
isCommitted() | True once the player committed and blocks started changing |
cancel() | End the session, rolling back a running construction. False when it already ended |