Paper Plugin Guide
File mode0

Paper essentials

Saving player data: files and databases

Store homes, stats and settings in YAML, JSON or a database without lagging the server.

Intermediate1 min read

This page is still being written.

What it will cover

  • Choosing storage: PDC vs YAML files vs JSON vs SQLite vs MySQL/MariaDB (table)
  • Per-player YAML files in the data folder; load on join, save on quit and on disable
  • JSON with Gson (bundled with Paper) and records
  • Doing file and database work off the main thread (runTaskAsynchronously) and coming back
  • SQLite or MySQL via JDBC: connection, prepared statements (never string concatenation; SQL injection), table creation; note on drivers and the plugin.yml libraries field or loader; HikariCP mention
  • Caching in a Map<UUID, Data> and autosave task
  • Example plugin: player stats saved to YAML per player with async saving (plugins/player-data)