Bukkit and BungeeCord library for asynchronous execution of SQL queries
Are you tired of syncing results of asynchronously executed methods back to the server thread? Do you want to easily configure your connection pools? Then this library is for you!
All tasks you submit using this library are executed asynchronously. After a task completes (either normally or by throwing an exception), its callback method is executed in the server thread (Bukkit plugins) or in one of the plugin threads (Bungee plugins). This library uses HikariCP as the main connection pool. More information on GitHub .
This library is also available as a BungeeCord plugin .
Dependencies :
Example:
1. Create a repository by extending PluginSqlTaskSubmitter :
public final class UserRepository extends PluginSqlTaskSubmitter {
public UserRepository ( JavaPlugin plugin ) { super ( plugin ) ; }
public void getUser ( UUID uuid, BiConsumer < User, Throwable > callback ) {
String query = "SELECT * FROM `users` WHERE `uuid` = ?" ;
// you can submit different types of tasks
submitSqlPreparedStatementTask ( query, preparedStatement -> {
// executed asynchronously
preparedStatement. setString ( 1 , uuid. toString ( ) ) ;
ResultSet rs = preparedStatement. executeQuery ( ) ;
return rs. next ( )
? new User ( uuid, rs. getString ( "email" ) )
: null ;
} , callback ) ;
}
}
2. Use your repository:
final class ExamplePlugin extends JavaPlugin {
private UserRepository userRepository ;
@Override
public void onEnable ( ) {
userRepository = new UserRepository ( this ) ;
userRepository. getUser ( UUID. fromString ( "..." ) , ( user, throwable ) -> {
// executed in the server-thread or a plugin-thread.
if ( throwable != null ) {
System . err . println ( "exception: " + throwable ) ;
} else {
System . out . println ( "result: " + user ) ;
}
} ) ;
}
}Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta