1 Jobs API
Jesse Boyd edited this page 2016-08-16 00:23:37 +10:00

Something sorta exists resembling a Job API.

SetQueue

This class is a queue of local queues. Each local queue is a queue of chunk changes, and may have an associated EditSession which may have an associated player.

The SetQueue will track active and inactive queues:

// Active queues are finished queuing
Collection<FaweQueue> active = SetQueue.IMP.getActiveQueues();
// Inactive queues may still be queueing chunk changes or doing something
Collection<FaweQueue> inactive = SetQueue.IMP.getInactiveQueues();
Collection<FaweQueue> all = SetQueue.IMP.getAllQueues();

Example: Getting the queued blocks for a player!

You can get the EditSessions currently running for a player: FawePlayer#getTrackedSessions.
From each EditSession you can get the changed blocks: EditSession#getLimitUsed, though this does not necessarily correspond to the current blocks in the queue (as the queue empties as it's dispatching.

Or from the FaweQueue (EditSession#getQueue), you can get the active chunks: FaweQueue#getFaweChunks, then each active chunk can be cast to a CharFaweChunk and use CharFaweChunk#getTotalCount

Cancel an edit

Simply use EditSession#cancel after obtaining the correct EditSession.