ModsJava
[UTIL] ⭐ASync Database Util!⭐
Java mod listed for Minecraft 1.7–1.16. Download on the author's site.
Installation Maven: Code (XML): <repositories > <repository > <id > jitpack.io </id > <url > </url > </repository > </repositories > <dependencies >…
⬇ Download on SpigotInstallation
Maven:
Gradle:
Usage preparation
1: Create your databaseConnection
2: Create your database class
3: Lets make your database class accessible
Usage Examples
NOTE: All your methods with database query's needs to be in your database class (in my case "TestDatabase")
Select:
Select async method 1:
Select async method 2
Update:
Update async:
Insert:
Insert async:
Good luck!
Maven:
Code (XML):
<repositories>
<repository>
<id>jitpack.io </id>
<url>https://jitpack.io </url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.jarnoboy404 </groupId>
<artifactId>Databases </artifactId>
<version>2.0 </version>
</dependency>
</dependencies>
<repository>
<id>jitpack.io </id>
<url>https://jitpack.io </url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.jarnoboy404 </groupId>
<artifactId>Databases </artifactId>
<version>2.0 </version>
</dependency>
</dependencies>
Code (gradle (Unknown Language)):
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.jarnoboy404:Databases:2.0'
}
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.jarnoboy404:Databases:2.0'
}
1: Create your databaseConnection
Code (Java):
private DatabaseConnection databaseConnection
;
@Override
public void onEnable ( ) {
try {
databaseConnection = new DatabaseConnection ( "localhost", 3306, "MyDatabase", "root", "password", 4 ) ;
} catch (HikariPool. PoolInitializationException e ) {
Bukkit. getConsoleSender ( ). sendMessage ( "Failed to connect to localhost database" ) ;
Bukkit. getPluginManager ( ). disablePlugin ( this ) ;
return ;
}
}
@Override
public void onEnable ( ) {
try {
databaseConnection = new DatabaseConnection ( "localhost", 3306, "MyDatabase", "root", "password", 4 ) ;
} catch (HikariPool. PoolInitializationException e ) {
Bukkit. getConsoleSender ( ). sendMessage ( "Failed to connect to localhost database" ) ;
Bukkit. getPluginManager ( ). disablePlugin ( this ) ;
return ;
}
}
Code (Java):
public
class TestDatabase
extends DatabaseConnection
{
public TestDatabase (DatabaseConnection databaseConnection ) {
super (databaseConnection ) ;
}
}
public TestDatabase (DatabaseConnection databaseConnection ) {
super (databaseConnection ) ;
}
}
Code (Java):
public
static TestDatabase testDatabase
;
private DatabaseConnection databaseConnection ;
@Override
public void onEnable ( ) {
try {
databaseConnection = new DatabaseConnection ( "localhost", 3306, "MyDatabase", "root", "password", 4 ) ;
} catch (HikariPool. PoolInitializationException e ) {
Bukkit. getConsoleSender ( ). sendMessage ( "Failed to connect to localhost database" ) ;
Bukkit. getPluginManager ( ). disablePlugin ( this ) ;
return ;
}
testDatabase = new TestDatabase (databaseConnection ) ;
}
private DatabaseConnection databaseConnection ;
@Override
public void onEnable ( ) {
try {
databaseConnection = new DatabaseConnection ( "localhost", 3306, "MyDatabase", "root", "password", 4 ) ;
} catch (HikariPool. PoolInitializationException e ) {
Bukkit. getConsoleSender ( ). sendMessage ( "Failed to connect to localhost database" ) ;
Bukkit. getPluginManager ( ). disablePlugin ( this ) ;
return ;
}
testDatabase = new TestDatabase (databaseConnection ) ;
}
NOTE: All your methods with database query's needs to be in your database class (in my case "TestDatabase")
Select:
Code (Java):
public
String getUser
(UUID uuid
)
{
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
DatabaseResult result = executeQuery ( "SELECT * FROM `playerdata`" + queryParam. getWhereQuery ( ) ) ;
String user = null ;
if (result. getResult ( ) ) user = result. getString ( "user" ) ;
result. endResult ( ) ;
return user ;
}
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
DatabaseResult result = executeQuery ( "SELECT * FROM `playerdata`" + queryParam. getWhereQuery ( ) ) ;
String user = null ;
if (result. getResult ( ) ) user = result. getString ( "user" ) ;
result. endResult ( ) ;
return user ;
}
Code (Java):
public CompletableFuture
<String
> getUser
(UUID uuid
)
{
return CompletableFuture. supplyAsync ( ( ) -> {
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
DatabaseResult result = executeQuery ( "SELECT * FROM `playerdata`" + queryParam. getWhereQuery ( ) ) ;
String user = null ;
if (result. getResult ( ) ) user = result. getString ( "user" ) ;
result. endResult ( ) ;
return user ;
} ) ;
}
return CompletableFuture. supplyAsync ( ( ) -> {
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
DatabaseResult result = executeQuery ( "SELECT * FROM `playerdata`" + queryParam. getWhereQuery ( ) ) ;
String user = null ;
if (result. getResult ( ) ) user = result. getString ( "user" ) ;
result. endResult ( ) ;
return user ;
} ) ;
}
Code (Java):
public CompletableFuture
<DatabaseResult
> getUser
(UUID uuid
)
{
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
return executeQueryAsync ( "SELECT * FROM `playerdata`" + queryParam. getWhereQuery ( ) ) ;
}
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
return executeQueryAsync ( "SELECT * FROM `playerdata`" + queryParam. getWhereQuery ( ) ) ;
}
Code (Java):
public
void updateUser
(UUID uuid
)
{
QueryParam updateQuery = new QueryParam ( ) ;
updateQuery. addQueryParam ( "uuid", uuid ) ;
QueryParam whereQuery = new QueryParam ( ) ;
whereQuery. addQueryParam ( "uuid", uuid ) ;
executeUpdate (updateQuery. getUpdateQuery ( "playerdata", whereQuery ) ) ;
}
QueryParam updateQuery = new QueryParam ( ) ;
updateQuery. addQueryParam ( "uuid", uuid ) ;
QueryParam whereQuery = new QueryParam ( ) ;
whereQuery. addQueryParam ( "uuid", uuid ) ;
executeUpdate (updateQuery. getUpdateQuery ( "playerdata", whereQuery ) ) ;
}
Code (Java):
public CompletableFuture
<Void
> updateUser
(UUID uuid
)
{
QueryParam updateQuery = new QueryParam ( ) ;
updateQuery. addQueryParam ( "uuid", uuid ) ;
QueryParam whereQuery = new QueryParam ( ) ;
whereQuery. addQueryParam ( "uuid", uuid ) ;
return executeUpdateAsync (updateQuery. getUpdateQuery ( "playerdata", whereQuery ) ) ;
}
QueryParam updateQuery = new QueryParam ( ) ;
updateQuery. addQueryParam ( "uuid", uuid ) ;
QueryParam whereQuery = new QueryParam ( ) ;
whereQuery. addQueryParam ( "uuid", uuid ) ;
return executeUpdateAsync (updateQuery. getUpdateQuery ( "playerdata", whereQuery ) ) ;
}
Code (Java):
public
void createUser
(UUID uuid,
String user
)
{
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
queryParam. addQueryParam ( "user", user ) ;
executeUpdate (queryParam. getInsertQuery ( "playerdata" ) ) ;
}
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
queryParam. addQueryParam ( "user", user ) ;
executeUpdate (queryParam. getInsertQuery ( "playerdata" ) ) ;
}
Code (Java):
public CompletableFuture
<Void
> createUser
(UUID uuid,
String user
)
{
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
queryParam. addQueryParam ( "user", user ) ;
return executeUpdateAsync (queryParam. getInsertQuery ( "playerdata" ) ) ;
}
QueryParam queryParam = new QueryParam ( ) ;
queryParam. addQueryParam ( "uuid", uuid ) ;
queryParam. addQueryParam ( "user", user ) ;
return executeUpdateAsync (queryParam. getInsertQuery ( "playerdata" ) ) ;
}
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.
[UTIL] ⭐ASync Database Util!⭐ is a free Minecraft Java mod. Compatible with Minecraft 1.7, 1.8, 1.9, 1.10 and newer. Downloaded 76 times (via Spigot). Download it and open it directly in the game.