Skip to content

Commit

Permalink
fix: use h2 connector properly
Browse files Browse the repository at this point in the history
  • Loading branch information
broccolai committed Nov 18, 2022
1 parent de9356e commit c43ce56
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 5 additions & 2 deletions bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.gradle.kotlin.dsl.withType

plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
id("xyz.jpenilla.run-paper") version "2.0.0"
}

apply<ShadowPlugin>()
Expand Down Expand Up @@ -37,17 +38,19 @@ tasks {
"net.kyori.event",
"net.kyori.coffee",
"org.objectweb.asm",
"org.flyway",
"broccolai.corn"
)

archiveFileName.set(project.name + ".jar")
minimize()
}

getByName("build") {
dependsOn(withType<ShadowJar>())
}

runServer {
minecraftVersion("1.19.2")
}
}

fun ShadowJar.relocate(group: Any, vararg dependencies: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class StorageConfiguration {

@Setting
@Comment("Storage method. Current options are: LUCKPERMS, SQLITE")
public StorageMethod storageMethod = StorageMethod.LUCKPERMS;
@Comment("Storage method. Current options are: LUCKPERMS, H2")
public StorageMethod storageMethod = StorageMethod.H2;

}
12 changes: 7 additions & 5 deletions core/src/main/java/broccolai/tags/core/inject/PluginModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public final class PluginModule extends AbstractModule {

Expand All @@ -27,12 +29,12 @@ public final class PluginModule extends AbstractModule {

//todo(josh): cleanup
if (configuration.storage.storageMethod == StorageMethod.H2) {
File file = new File(folder, "tags.db");
file.mkdirs();
if (!file.exists()) {
file.createNewFile();
Path file = folder.toPath().resolve("storage.db");
if (!Files.exists(file)) {
Files.createFile(file);
}
hikariConfig.setJdbcUrl("jdbc:h2:" + file.getAbsolutePath() + ";MODE=MySQL;DATABASE_TO_LOWER=TRUE");
hikariConfig.setDriverClassName("org.h2.Driver");
hikariConfig.setJdbcUrl("jdbc:h2:" + file.toAbsolutePath() + ";MODE=MySQL;DATABASE_TO_LOWER=TRUE");
}

hikariConfig.setMaximumPoolSize(10);
Expand Down

0 comments on commit c43ce56

Please sign in to comment.