SQL Module

Module must be shaded to your JAR file

{VERSION} - current version form GitHub releases section: https://github.com/timsixth/MinigameAPI/releases

<repositories>
  <repository>
   <id>jitpack.io</id>
   <url>https://jitpack.io</url>
  </repository>
</repositories>

<dependency>
   <groupId>com.github.timsixth.MinigameAPI</groupId>
   <artifactId>sql-databases-support</artifactId>
   <version>{VERSION}</version>
</dependency>

How to register SQL Module?

//Use SQLLibraryConfiguration instend of LibraryConfiguration
    //Type list with SQLModule
    @Override
    protected LibraryConfiguration configure() {
        return new SQLLibraryConfiguration(this, getConfiguratorsInitializer(),
                () -> Collections.singletonList(new SQLModule())) //you can register modules before others
                .builder()
                .setGameManager(new MyGameManager(this, settings, messages))
                .build();
    }

with custom SQL module configuration (Optional but recommended)

    @Override
    protected LibraryConfiguration configure() {
        return new SQLLibraryConfiguration(this, getConfiguratorsInitializer(),
                () -> Collections.singletonList(new SQLModule(new MySQLModuleConfigurator().configure()))) //you can register modules before others
                .builder()
                .setGameManager(new MyGameManager(this, settings, messages))
                .build();
    }

How to define SQL Module configurator (Optional)?

public class MySQLModuleConfigurator extends DefaultSQLModuleConfigurator {

    @Override
    public SQLModuleConfiguration configure() {
        return SQLModuleConfiguration.builder()
                .sqlDatabaseAdapter(new CustomSQLDatabaseAdapter()) //if you want to create your own SQL Database adapter
                .sqlDatabaseMigrator(new CustomDatabaseMigrator()) //if you want to create your own SQL Database migrator
                .build();
    }
}

Last updated