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)
- 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):
Connecting to a database
JDBC (MySQL)
- The
driver
field should always be set tomysql
, as the plugin comes bundled with only themysql
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 theport
field). - The
database
field should reflect the existing database in which the UnderscoreEnchants data table will be created. username
andpassword
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 theport
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 thecollection
field. username
andpassword
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)