-
Notifications
You must be signed in to change notification settings - Fork 21
Storage
By default void saves players to /data/saves/*.json
however when running in a production environment you might want to store in a database rather than json files, void support PostgreSQL out of the box, and other SQL databases with a little modification.
Storage using Postgresql is simple, replace the storage=files
line in game.properties
with storage=database
and fill out the following details about your database:
storage=database
database_username=postgres # The database username
database_password=password # The database password
database_driver=org.postgresql.Driver # The database driver - see JDBC
database_jdbc_url=jdbc:postgresql://localhost:5432/game?reWriteBatchedInserts=true
database_pool=4 # Number of connections to use
Java database connectivity (JDBC) is a specification for connecting to multiple types of SQL databases. By default Void only comes bundled with the Postgresql Driver but can support all major database providers.
Follow these steps to add support for your desired database, for this example we will add support for MySQL:
- In
/engine/build.gradle.kts
add the driver for the database of your choosing
implementation("com.mysql:mysql-connector-j:8.3.0")
- Build your server .jar on the command line by running
./gradlew assembleBundleDist
Which will create /game/build/distributions/void-dev.zip
for you to use.
- In
game.properties
set the driver class name
database_driver=com.mysql.jdbc.Driver
database_jdbc_url=jdbc:mysql://localhost:3306/game
Tip
This information can be found by googling "mysql jdbc driver maven" and "mysql jdbc driver class name"