Class PaintService
Public operations are synchronized and a ticker on the global region drives the job. Creation validates bounds, budgets, history capacity and journal overlap. Chunk tickets are acquired incrementally and loaded asynchronously before a scan captures ordinary block data. A worker saves the complete journal before painting writes are allowed.
Block access is grouped by chunk. Each batch runs on the region scheduler of its chunk, one batch at a time, so the service works on Paper's single server thread and on Folia's regionized threads alike. Batch results are merged under the service lock.
Restoration changes only blocks that still match the intended output. Later edits and block entities are preserved; conflicts retain the journal. Cancel, disconnect and shutdown release world resources while retaining any durable record needed to restore partial work.
-
Constructor Summary
ConstructorsConstructorDescriptionPaintService(PixelPainter plugin, UndoStore store, List<PaintRecord> restored) Publishes recovered journals and registers the global-region ticker. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbusy()Checks whether a world job, including pending journal I/O, occupies the service.voidcancel(org.bukkit.entity.Player player) Cancels the caller's active job, or any job for an administrator.voidclose()Cancels the ticker and releases active chunk tickets and the progress bar.voidcreate(org.bukkit.entity.Player player, String image, PaintPlan plan, Orientation orientation, Position origin, UUID worldId, Settings settings, boolean ignoreBorder) Validates and queues a prepared image for incremental capture and painting.history(org.bukkit.entity.Player player) Lists journals accessible to a player in newest-first order.voidStops a departing owner's job while retaining durable undo data.voidQueues restoration of the latest accessible or explicitly requested journal.booleanChecks whether the active job holds resources in a world.
-
Constructor Details
-
PaintService
Publishes recovered journals and registers the global-region ticker.- Parameters:
plugin- owning enabled pluginstore- persistent journal storagerestored- startup recovery records
-
-
Method Details
-
busy
public boolean busy()Checks whether a world job, including pending journal I/O, occupies the service.- Returns:
- whether a job is active
-
usesWorld
Checks whether the active job holds resources in a world.- Parameters:
world- queried world UUID- Returns:
- whether that world is in use
-
history
Lists journals accessible to a player in newest-first order.- Parameters:
player- owner or administrator with pp.admin- Returns:
- copied list of accessible records
-
create
public void create(org.bukkit.entity.Player player, String image, PaintPlan plan, Orientation orientation, Position origin, UUID worldId, Settings settings, boolean ignoreBorder) Validates and queues a prepared image for incremental capture and painting.- Parameters:
player- requesting player; command layer checks creation permissionimage- source nameplan- prepared pixel materialsorientation- image-to-world mappingorigin- bottom-left image blockworldId- world captured when preparation startedsettings- captured request limitsignoreBorder- whether a painting may extend past the world border- Throws:
PaintException- if world, bounds, capacity or overlap checks fail
-
undo
Queues restoration of the latest accessible or explicitly requested journal.- Parameters:
player- owner or administrator; command layer checks undo permissionrequested- identifier or source name, or null for the latest accessible journal- Throws:
PaintException- if no journal matches or restoration cannot start
-
cancel
public void cancel(org.bukkit.entity.Player player) Cancels the caller's active job, or any job for an administrator.- Parameters:
player- requesting owner or administrator- Throws:
PaintException- if the player has no cancellable job
-
quit
Stops a departing owner's job while retaining durable undo data.- Parameters:
owner- departing player UUID
-
close
public void close()Cancels the ticker and releases active chunk tickets and the progress bar.
-