ModsJava
SQL Library
Java mod listed for Minecraft 1.7–1.17. Download on the author's site.
Gradle Code (Text): repositories { maven { url(' allowInsecureProtocol(true) } } dependencies { implementation('eu.byncing:sql-lib:2.0.3-SNAPSHOT') } A…
⬇ Download on SpigotGradle
A small example of how to add a player to the database.
How to create a SqlLib instance.
How to connect to sql server.
Create a table with keys and data types
Create a PlayerData class
Retrieve a table
Here the online value is changed by the player byncing.
Here is a player data class with which you can serialize and deserialize the player.
Code (Text):
repositories {
maven {
url('http://repo.byncing.eu/snapshots')
allowInsecureProtocol(true)
}
}
dependencies {
implementation('eu.byncing:sql-lib:2.0.3-SNAPSHOT')
}
maven {
url('http://repo.byncing.eu/snapshots')
allowInsecureProtocol(true)
}
}
dependencies {
implementation('eu.byncing:sql-lib:2.0.3-SNAPSHOT')
}
A small example of how to add a player to the database.
How to create a SqlLib instance.
Code (Java):
SqlLib lib
=
new SqlLib
(
)
;
How to connect to sql server.
Code (Java):
lib.
connect
(
new Profile
(
"127.0.0.1",
3306,
"root",
"bridge",
""
)
)
;
Create a table with keys and data types
Code (Java):
Table table
= lib.
table
(
"players"
)
;
table. setKeys ( "UUID", "NAME", "CREATE_TIME", "ONLINE" ) ;
table. setTypes (DataTypes. STRING, DataTypes. STRING, DataTypes. LONG, DataTypes. BOOLEAN ) ;
table. createTable ( ) ;
table. setKeys ( "UUID", "NAME", "CREATE_TIME", "ONLINE" ) ;
table. setTypes (DataTypes. STRING, DataTypes. STRING, DataTypes. LONG, DataTypes. BOOLEAN ) ;
table. createTable ( ) ;
Create a PlayerData class
Code (Java):
PlayerData data
=
new PlayerData
(UUID.
randomUUID
(
),
"byncing",
System.
currentTimeMillis
(
),
true
)
;
Retrieve a table
Code (Java):
table.
fetch
(fetch
->
{
if ( !fetch. find ( "NAME", "byncing" ) ) {
table. insert (data. serialize ( ) ) ;
}
fetch. setWhere ( "NAME" ). setWhereValues ( "byncing" ) ;
PlayerData playerData = PlayerData. deserialize (fetch. single ( "UUID", "NAME", "CREATE_TIME", "ONLINE" ) ) ;
System. out. println (playerData ) ;
}, true ) ;
if ( !fetch. find ( "NAME", "byncing" ) ) {
table. insert (data. serialize ( ) ) ;
}
fetch. setWhere ( "NAME" ). setWhereValues ( "byncing" ) ;
PlayerData playerData = PlayerData. deserialize (fetch. single ( "UUID", "NAME", "CREATE_TIME", "ONLINE" ) ) ;
System. out. println (playerData ) ;
}, true ) ;
Here the online value is changed by the player byncing.
Code (Java):
table.
update
(update
->
{
update. setWhere ( "NAME" ). setWhereValues ( "byncing" ) ;
table. fetch (fetch -> {
fetch. setWhere ( "NAME" ). setWhereValues ( "byncing" ) ;
update. setKeys ( "ONLINE" ). change ( !fetch. single ( "ONLINE", Boolean. class ) ) ;
}, false ) ;
}, true ) ;
update. setWhere ( "NAME" ). setWhereValues ( "byncing" ) ;
table. fetch (fetch -> {
fetch. setWhere ( "NAME" ). setWhereValues ( "byncing" ) ;
update. setKeys ( "ONLINE" ). change ( !fetch. single ( "ONLINE", Boolean. class ) ) ;
}, false ) ;
}, true ) ;
Here is a player data class with which you can serialize and deserialize the player.
Code (Java):
public
class PlayerData
{
private final UUID uniqueId ;
private final String name ;
private final long createTime ;
private boolean online ;
public PlayerData (UUID uniqueId, String name, long createTime, boolean online ) {
this. uniqueId = uniqueId ;
this. name = name ;
this. createTime = createTime ;
this. online = online ;
}
public Object [ ] serialize ( ) {
return new Object [ ] {uniqueId, name, createTime, online } ;
}
public static PlayerData deserialize (Map < String, Object > values ) {
return new PlayerData (
UUID. fromString ( ( String ) values. get ( "UUID" ) ),
( ( String ) values. get ( "NAME" ) ),
( ( Long ) values. get ( "CREATE_TIME" ) ),
( ( Boolean ) values. get ( "ONLINE" ) ) ) ;
}
public UUID getUniqueId ( ) {
return uniqueId ;
}
public String getName ( ) {
return name ;
}
public long getCreateTime ( ) {
return createTime ;
}
public boolean isOnline ( ) {
return online ;
}
public void setOnline ( boolean online ) {
this. online = online ;
}
}
private final UUID uniqueId ;
private final String name ;
private final long createTime ;
private boolean online ;
public PlayerData (UUID uniqueId, String name, long createTime, boolean online ) {
this. uniqueId = uniqueId ;
this. name = name ;
this. createTime = createTime ;
this. online = online ;
}
public Object [ ] serialize ( ) {
return new Object [ ] {uniqueId, name, createTime, online } ;
}
public static PlayerData deserialize (Map < String, Object > values ) {
return new PlayerData (
UUID. fromString ( ( String ) values. get ( "UUID" ) ),
( ( String ) values. get ( "NAME" ) ),
( ( Long ) values. get ( "CREATE_TIME" ) ),
( ( Boolean ) values. get ( "ONLINE" ) ) ) ;
}
public UUID getUniqueId ( ) {
return uniqueId ;
}
public String getName ( ) {
return name ;
}
public long getCreateTime ( ) {
return createTime ;
}
public boolean isOnline ( ) {
return online ;
}
public void setOnline ( boolean online ) {
this. online = online ;
}
}
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.7, 1.8, 1.9
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
SQL Library is a free Minecraft Java mod. Compatible with Minecraft 1.7, 1.8, 1.9, 1.10 and newer. Downloaded 448 times (via Spigot). Download it and open it directly in the game.