Class ExpirySweeper

java.lang.Object
com.enhancedechest.expiry.ExpirySweeper

public final class ExpirySweeper extends Object
Periodically scans for expired chests and disposes of them.

Runs on an async repeating timer at the configured check-interval. Each sweep calls findExpired — a DB-side candidate query (the only way to see offline, non-resident owners' expired chests) whose hits are loaded into the cache and re-verified against the authoritative in-memory rows, plus a scan of already-resident owners — and routes each hit through ChestSpillService:

  • a NORMAL chest is removed with its items spilled into a temp chest (force = false);
  • a TEMP chest is hard-deleted, its remaining items lost (force = true).
Both paths reuse the service's force-close + per-(owner,index) serialization, so expiry is just as dupe-safe as a manual delete. Centralising the dangerous mutation here keeps the hot open/close path free of any expiry filtering.
  • Constructor Details

  • Method Details

    • start

      public void start()
      Starts the repeating async sweep. Safe to call once during plugin enable.
    • reschedule

      public void reschedule(long newIntervalMillis)
      Re-applies a possibly-changed sweep interval after a /ee reload.

      No-op when the interval is unchanged, so repeated reloads neither reset the countdown nor churn timers. When it does change and the sweeper is running, the old timer is cancelled and a fresh one started — there is never more than one live task, so no leak. If the sweeper is not running the value is simply stored for the next start().

    • stop

      public void stop()
      Cancels the repeating sweep. Safe to call even if never started.