The easiest way to store data for all your minecraft needs!
![]()
SQLib is the easiest way to store data for all your minecraft needs! A simple sql wrapper made with a focus on minecraft use cases.
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.
The mod generates a config on first time start that allows you to configure the database used by all mods relying on sqlib.
The default database is a sqlite database running in the sqlib directory.
The datatypes can be accessed via JavaTpes, MinecraftTypes or the AdventureTypes classes. I tend to add support for new types as I run into them in my projects. If you would like one added, pleade make an issue!
| Standard | Minecraft | Adventure |
|----------|-------------|-----------|
| Byte | Vec3i | Key |
| Byte[] | BlockPos | Component |
| Bool | ChunkPos | |
| Short | Text | |
| Int | Identifier | |
| Float | Sound | |
| Double | Json | |
| Long | NbtElement | |
| String | | |
| Char | | |
| Date | | |
| Color | | |
| UUID | | |
| URI | | |
| URL | | |
You can also add your own custom types as seen here:
In your build.gradle include:
repositories {
maven { url "https://api.modrinth.com/maven" }
}
dependencies {
modImplementation("maven.modrinth:sqlib:3.2.2")
}
This example uses the built-in database managed by sqlib. for 99% of mods, using the built-in database is good, however
further down are examples for custom database management.
// Do not call SQLib.getDatabase() in a early mod initializer. Doing so will likely crash your mod.
// Calling in or after the regular mod initializer is ok.
Database db = SQLib.getDatabase();
DataStore store = db.dataStore("myModId", "userdata");
DataContainer playerData = store.createDataContainer();
playerData.put(JavaTypes.STRING, "username", "CoolGuy123");
playerData.put(MinecraftTypes.BLOCKPOS, "home", new BlockPos(304, 62, 37));
playerData.put(MinecraftTypes.NBT, "nbt", new NbtCompound());
System.out.println(playerdata.get(JavaTypes.STRING, "username"));
System.out.println(playerdata.get(MinecraftTypes.BLOCKPOS, "home"));
System.out.println(playerdata.get(MinecraftTypes.NBT, "nbt"));
Postgres db = new Postgres("name", "192.168.1.69", "3306", "cooluser", "radman");
// OR
MySQL db = new MySQL("name", "192.168.1.69", "3306", "cooluser", "radman");
// OR
SQLite db = new SQLite("name", "some/dir");
This approach will bach sql commands into one command for faster read/writes of large amounts of data.
DataStore store = db.dataStore("modId", "userdata");
DataContainer playerData = table.createDataContainer();
playerData.transaction().put("username", "CoolGuy123").put("home", new BlockPos(304, 62, 37).commit();
You can add a custom type by following the implentations in JavaTypes, MinecraftTypes and AdventureTypes. Then you can use it like any other native SQLib type.
// The SQLPrimitive is the base type to serialize to, and the two function lambdas are to serialize and deserialize from it
public static final SQLibType<JsonElement> JSON = new SQLibType<>(SQLPrimitive.STRING, JsonElement::toString, JsonParser::parseString);
// You can also extend a type like this:
public static final SQLibType<Identifier> IDENTIFIER = new SQLibType<>(SQLPrimitive.STRING, Identifier::toString, Identifier::tryParse);
public static final SQLibType<SoundEvent> SOUND = new SQLibType<>(IDENTIFIER, SoundEvent::getId, SoundEvent::of);
Optional
Optional
Умови використання, зміни та поширення цього товару.
21.03.2025 · Modrinth
/ on linuxСкриншоти та зображення з оригінальної сторінки Modrinth.
Опубліковані версії та оригінальні файли Modrinth.
21.03.2025 · 1 395 завантаження
/ on linux05.02.2025 · 786 завантаження
05.02.2025 · 140 завантаження
05.02.2025 · 135 завантаження
SQLibConfig that allow for setting the config and default database directory, allowing for sqlib to be used in unsupported mod loads and even outside of minecraft21.12.2024 · 573 завантаження
26.11.2024 · 287 завантаження
DataStore function getOrCreateDefaultContainer to cover the most common on create lambda23.10.2024 · 464 завантаження
20.09.2024 · 422 завантаження
11.08.2024 · 312 завантаження
27.07.2024 · 338 завантаження
22.07.2024 · 310 завантаження
21.07.2024 · 250 завантаження
21.07.2024 · 283 завантаження
21.07.2024 · 236 завантаження
19.07.2024 · 264 завантаження
DataStore Lookup functions to use optionals instead of returning null for that sweet sweet functional goodness18.07.2024 · 253 завантаження
SQLib.getDatabase() to be called much earlier17.07.2024 · 233 завантаження
16.07.2024 · 245 завантаження
onCreate function to the DataStore.getOrCreateContainer() functions16.07.2024 · 267 завантаження
DataStores and DataContainers to be compared using .equals()DataContainer15.07.2024 · 250 завантаження
getContainer() fails15.07.2024 · 214 завантаження
15.07.2024 · 192 завантаження
30.01.2024 · 576 завантаження
22.01.2024 · 241 завантаження
19.01.2024 · 205 завантаження
19.01.2024 · 327 завантаження
16.01.2024 · 181 завантаження
DataContainer .put() calls DataContainer .get() calls instead of just printing an error16.01.2024 · 195 завантаження
03.12.2023 · 307 завантаження
25.11.2023 · 197 завантаження
24.11.2023 · 140 завантаження
23.11.2023 · 133 завантаження
16.11.2023 · 174 завантаження
getDataContainers()16.11.2023 · 154 завантаження
15.11.2023 · 194 завантаження
15.11.2023 · 70 завантаження
me.mrnavastar - you will have to fix your projects sorry :(GetOrCreateDataContainer() util function15.11.2023 · 57 завантаження
table.getIds()09.10.2023 · 105 завантаження
09.10.2023 · 62 завантаження
09.10.2023 · 66 завантаження
06.07.2023 · 285 завантаження
database.getTables()10.06.2023 · 81 завантаження
11.05.2023 · 59 завантаження
09.05.2023 · 100 завантаження
07.05.2023 · 61 завантаження
03.05.2023 · 51 завантаження
30.04.2023 · 70 завантаження