LocationStore

In-memory index over every despawn location. Replaces the old flat ArrayList that was copied and linearly scanned on every query and rewritten to disk in full on every change. Provides:

  • O(1) add, remove, contains and owner/block lookups;

  • a spatial index (byBlock) — block position → owners at that block;

  • an owner index (byOwner) — owner → their locations (for limits & bulk ops);

  • a flat bag with swap-remove for O(1) uniform randomOrNull draw;

  • dirty-owner tracking so persistence writes only the owners that changed.

Not thread-safe by design: it is mutated only from the server main thread (events and commands). Async persistence takes a snapshot on the main thread first.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val size: Int

Total number of stored locations.

Functions

Link copied to clipboard

Adds loc. Returns false (no-op) if that owner already has that block.

Link copied to clipboard

Immutable snapshot of all locations.

Link copied to clipboard

Locations registered at key (one per owner).

Link copied to clipboard
fun clear()

Removes everything. Every previously-known owner is marked dirty so files are rewritten.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun countOfOwner(owner: UUID): Int

How many locations owner has (used for per-user limits).

Link copied to clipboard

Owners whose data changed since the last clearDirty.

Link copied to clipboard
Link copied to clipboard

Owners that currently have at least one location (for full flush / file cleanup).

Link copied to clipboard
Link copied to clipboard

All locations owned by owner.

Link copied to clipboard

Owners registered at key.

Link copied to clipboard

A uniformly random location (with replacement), or null if empty.

Link copied to clipboard

Removes loc. Returns false if it was not present.

Link copied to clipboard
fun removeAt(key: BlockKey): Int

Removes every location at key regardless of owner; returns how many.

Link copied to clipboard
fun removeOwner(owner: UUID): Int

Removes every location owned by owner; returns how many were removed.

Link copied to clipboard

Replaces all contents with locations without marking anything dirty (used on load).