Skip to content

Repository files navigation

Maintenance
PRs WelcomeMIT license

SQLib

SQLib is the easiest way to store data for all your minecraft needs! Its simple fabric based sql wrapper made with a focus on minecraft use cases.

Important Note:

This library is not a full fledged sql wrapper, and does not provide full access to many sql features. The main focus of this library is to provide an easy and simple way to store data in your mods. If you are looking for a more advanced database I recommend taking a look at something like Nitrite.

Setup

The library first needs to be included into your project. The simplest way to do this is through Jitpack. In your build.gradle make sure to include:

repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
modImplementation 'com.github.MrNavaStar:SQLib:v1.2.0'//Or if you wish to include with the mod:
include(modImplementation('com.github.MrNavaStar:SQLib:v1.2.0'))
}

Usage

The database must first be setup to use either sqlite or mysql like so:

  • SQLITE
Databasedatabase = newSQLiteDatabase("name", "/awesome/dir");
  • MYSQL
Databasedatabase = newMySQLDatabase("name", "127.0.0.1", "3306", "username", "password");

Now a table can be added to store data. This table will automatically be added to the database (Note that it is not required to include your mod id in the table name, however doing so will result in less conflict with other mods that name their tables the same):

TableplayerData = database.createTable(MODID + " name");

In order to store data in the table you need a DataContainer object. This will simply provide a way to handle your data in an object orientied manner.

DataContainerplayer = playerData.createDataContainer(id);

Finally, you can use the DataContainer to put, get, and drop data:

player.put("NickName", "Bob Ross");
player.put("Health", 100);
Stringname = player.getString("NickName");
Stringhealth = player.getInt("Health");
player.dropString("NickName");
player.dropInt("Health");

About

The easiest way to store data for all your minecraft needs!

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages