Skip to content

Storing data

UnderscoreEnchants stores player data, specifically - their personal locale, the enchantments they have disabled, and their cooldowns. The storage medium is configurable - data can be stored in YAML or JSON files, or, if you are looking to scale your server into a network of multiple servers, you can use a MongoDB database or a MySQL database. (1)

  1. While explicit PostgreSQL and MariaDB support is not included in the plugin as of 2.2, you may still try using them. It should work fine.

Connection file

If you are planning on using a database, the connection credentials are stored in connection.json in the plugin's data folder. Here are the example contents:

{
  "connection": {
    "jdbc": {
      "driver": "mysql",
      "url": "localhost",
      "port": 3306,
      "database": "my_server",
      "username": "root",
      "password": ""
    },
    "mongo": {
      "url": "localhost",
      "database": "my_server",
      "collection": "underscore_enchants",
      "username": "bestest_username",
      "password": ""
    }
  }
}

Changing the storage medium

If you want to change the storage medium, open the configuration file config.json and change this value to what you want (refer to this):

"settings": {
  ...
  "storage-medium": "json",
  ...
},

Connecting to a database


JDBC (MySQL)

  • The driver field should always be set to mysql, as the plugin comes bundled with only the mysql driver. It should work even if you are trying to connect to a MariaDB or a PostgreSQL database - if it is not working, feel free to either open a ticket or submit a pull request to add this functionality.
  • For the url field, set the link to your database without the port (specify the port in the port field).
  • The database field should reflect the existing database in which the UnderscoreEnchants data table will be created.
  • username and password are your credentials for connecting to the database.

MongoDB

  • For MongoDB, the configuration is similar to JDBC. Specify the link to your database without the port in the url port and the port in the port field.
  • Choose the database you want to store the data in and put it in the database field; additionally, you can choose how to name the data collection using the collection field.
  • username and password are your credentials for connecting to the database.

Troubleshooting

If you are getting an error on startup that looks like it has something to do with connecting to a database (e.g. this):

[23:14:17] [DefaultDispatcher-worker-2/WARN]: Exception in thread "DefaultDispatcher-worker-2" java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
[23:14:17] [DefaultDispatcher-worker-2/WARN]:   at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:121)
[23:14:17] [DefaultDispatcher-worker-2/WARN]:   at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:113)
then you have probably messed up the credentials. Perhaps your user is not allowed to access the database you have specified, or the credentials are just incorrect. Double-check their validity and try again. Be especially careful if you are using Docker - you might have put in the incorrect URL.