Klasse RewardCache

java.lang.Object
de.delinkedde.mobarenareborn.reward.RewardCache

public final class RewardCache extends Object
A persistent hold-back store ("cache") for reward items that could not be delivered immediately.

When a player's inventory is full at reward time the overflow is kept here instead of being dropped, and delivered later - on their next join or via /ma claim - once they have space. The store is persisted to rewardcache.yml so it survives restarts and disconnects.

Item stacks are stored with Bukkit's built-in configuration serialization. This store is kept separate from the SQLite progression database so it never contends with the progression background thread.

  • Konstruktordetails

    • RewardCache

      public RewardCache(@NotNull @NotNull MobArenaPlugin plugin)
      Parameter:
      plugin - the owning plugin, used for the data folder and logging
  • Methodendetails

    • load

      public void load()
      Loads the cache from disk. Call once on start-up.
    • save

      public void save()
      Writes the cache to disk.
    • add

      public void add(@NotNull @NotNull UUID uuid, @NotNull @NotNull List<ItemStack> items)
      Adds items to a player's cache and persists.
      Parameter:
      uuid - the player's unique id
      items - the items to hold back
    • hasItems

      public boolean hasItems(@NotNull @NotNull UUID uuid)
      Parameter:
      uuid - the player's unique id
      Gibt zurück:
      whether the player has any cached reward items
    • deliver

      public int deliver(@NotNull @NotNull Player player)
      Delivers as many cached items as fit into the player's inventory and keeps the rest cached.
      Parameter:
      player - the player
      Gibt zurück:
      -1 if nothing was cached; otherwise the number of item stacks still cached afterwards (0 meaning everything was delivered)