Class PlayerVaultsXReader

java.lang.Object
com.enhancedechest.migration.PlayerVaultsXReader

public final class PlayerVaultsXReader extends Object
Reads a PlayerVaultsX installation's flat-file vault data and decodes it into Bukkit ItemStack arrays, ready to be re-encoded into EnhancedEchest's own storage.

Unlike AxVaults, PlayerVaultsX keeps no database: every player's vaults live in a single YAML file plugins/PlayerVaults/newvaults/<uuid>.yml (the plugin's plugin.yml name is "PlayerVaults", so that is its data folder even though the jar is "PlayerVaultsX"), one key per vault named vault1, vault2, … Each value is a MIME-Base64 string of PlayerVaultsX's CardboardBoxSerialization framing: a big-endian int slot count, then per slot a big-endian int byte length followed by that many bytes.

On a modern Paper server PlayerVaultsX's CardboardBox serializes each item with Paper's ItemStack.serializeAsBytes() (gzip-compressed NBT with a DataVersion), and encodes an empty/air slot as the single byte 0x0. So a non-empty slot decodes via ItemStack.deserializeBytes(byte[]) (which runs the DataFixerUpper across versions), and a one-byte 0x0 payload is an empty slot. This matches the data the test/target server itself produces; vault files written by an old non-Paper (Spigot) server use a different CardboardBox framing and are not handled here.

This reader is stateless and holds no resources — there is nothing to close. YAML parsing and item deserialization are read-only against the frozen server registries and safe off the main thread (the migration runs on the shared DB executor).

  • Constructor Details

    • PlayerVaultsXReader

      public PlayerVaultsXReader(Path playerVaultsFolder, org.slf4j.Logger log)
  • Method Details

    • sourceAvailable

      public boolean sourceAvailable()
      True if PlayerVaultsX vault data is present (the newvaults folder holds at least one file).
    • listOwners

      public List<UUID> listOwners() throws Exception
      Returns the owner UUIDs of every readable vault file in newvaults, skipping bad names.
      Throws:
      Exception
    • read

      public List<PlayerVaultsXReader.VaultRow> read(UUID owner) throws Exception
      Reads and decodes a single player's vaults, ordered by vault number. Empty if they have none.
      Throws:
      Exception