Skip to content

Commit 32c7c6f

Browse files
authored
Merge pull request #4 from MEFRREEX/feat/more-server-software
feat: more server software and fixes
2 parents eefb070 + ea5d53d commit 32c7c6f

File tree

11 files changed

+108
-14
lines changed

11 files changed

+108
-14
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Features:
1212
- MySQL support
1313
- Disabled printing logo and tips from JOOQ
1414
- Inclusion of JOOQ, SQLite and MySQL drivers in jar file
15+
- Support for different server software (Nukkit, PowerNukkitX, JukeboxMC, WaterdogPE)
1516

1617
## 🛠 Examples
1718

@@ -62,7 +63,7 @@ System.out.println("Value from table: " + value);
6263

6364
Example of using a MySQL database
6465
```java
65-
MySQLDatabase database = new MySQLDatabase("host", "database", "user", "password");
66+
MySQLDatabase database = new MySQLDatabase("127.0.0.1:3306", "database", "user", "password");
6667

6768
// Other code will be identical...
6869
```
@@ -71,7 +72,7 @@ Example of using SQlite or MySQL database
7172
```java
7273
IDatabase database = sqlite ?
7374
new SQLiteDatabase(new File("database.db")) :
74-
new MySQLDatabase("host", "database", "user", "password");
75+
new MySQLDatabase("127.0.0.1:3306", "database", "user", "password");
7576
```
7677

7778
You can make a separate class with methods for the database

api/src/main/java/com/mefrreex/jooq/database/MySQLDatabase.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mefrreex.jooq.exception.ConnectionNotEstablishedException;
44
import org.jooq.SQLDialect;
5+
import lombok.Getter;
56

67
import java.net.URLEncoder;
78
import java.nio.charset.StandardCharsets;
@@ -10,6 +11,7 @@
1011
import java.sql.SQLException;
1112
import java.util.concurrent.CompletableFuture;
1213

14+
@Getter
1315
public class MySQLDatabase implements IDatabase {
1416

1517
private final String host;
@@ -19,10 +21,7 @@ public class MySQLDatabase implements IDatabase {
1921
private Connection connection;
2022

2123
public MySQLDatabase(String host, String database, String user, String password) {
22-
if (!host.contains(":")) {
23-
throw new IllegalArgumentException("Host must be in format: address:port");
24-
}
25-
this.host = host;
24+
this.host = host.contains(":") ? host : host + ":3306";
2625
this.database = database;
2726
this.user = user;
2827
this.password = password;

api/src/main/java/com/mefrreex/jooq/database/SQLiteDatabase.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mefrreex.jooq.exception.ConnectionNotEstablishedException;
44
import org.jooq.SQLDialect;
5+
import lombok.Getter;
56

67
import java.io.File;
78
import java.io.IOException;
@@ -10,17 +11,18 @@
1011
import java.sql.SQLException;
1112
import java.util.concurrent.CompletableFuture;
1213

14+
@Getter
1315
public class SQLiteDatabase implements IDatabase {
1416

15-
private final File database;
17+
private final File file;
1618
private Connection connection;
1719

18-
public SQLiteDatabase(File database) {
19-
this.database = database;
20-
if (!database.exists()) {
20+
public SQLiteDatabase(File file) {
21+
this.file = file;
22+
if (!file.exists()) {
2123
try {
22-
if (!database.createNewFile()) {
23-
throw new IOException("Failed to create the database file.");
24+
if (!file.createNewFile()) {
25+
throw new IOException("Failed to create the database file");
2426
}
2527
} catch (IOException e) {
2628
e.printStackTrace();
@@ -38,7 +40,7 @@ public CompletableFuture<Connection> getConnection() {
3840
return CompletableFuture.supplyAsync(() -> {
3941
try {
4042
if (connection == null || connection.isClosed()) {
41-
connection = DriverManager.getConnection("jdbc:sqlite:" + database.getAbsolutePath());
43+
connection = DriverManager.getConnection("jdbc:sqlite:" + file.getAbsolutePath());
4244
}
4345
return connection;
4446
} catch (SQLException e) {

build.gradle.kts

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tasks.build {
1313
allprojects {
1414
group = "com.mefrreex.jooqconnector"
1515
description = "jooqconnector"
16-
version = "1.0.0"
16+
version = "1.0.1"
1717
}
1818

1919
subprojects {
@@ -42,6 +42,10 @@ subprojects {
4242
}
4343
}
4444

45+
fun getArchiveName(): String {
46+
return name
47+
}
48+
4549
publishing {
4650
publications {
4751
create<MavenPublication>("maven") {

plugin-jukeboxmc/build.gradle.kts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
id("java")
3+
id("com.github.johnrengelman.shadow") version "8.1.1"
4+
}
5+
6+
repositories {
7+
maven("https://repo.jukeboxmc.eu/releases")
8+
maven("https://repo.jukeboxmc.eu/snapshots")
9+
}
10+
11+
dependencies {
12+
compileOnlyApi("org.jukeboxmc:JukeboxMC-API:1.0.0-SNAPSHOT")
13+
api(project(":api"))
14+
}
15+
16+
tasks.withType<Jar> {
17+
archiveFileName.set("JOOQConnector-JukeboxMC-${project.version}.jar")
18+
}
19+
20+
tasks.build {
21+
dependsOn(tasks.shadowJar)
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.mefrreex.jooq;
2+
3+
import org.jukeboxmc.api.plugin.Plugin;
4+
5+
public class JOOQConnectorJukeboxMC extends Plugin {
6+
7+
@Override
8+
public void onStartup() {
9+
JOOQConnector.setJOOQMessagesEnabled(false);
10+
}
11+
12+
@Override
13+
public void onEnable() {
14+
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: "JOOQConnector"
2+
version: "${project.version}"
3+
author: "MEFRREEX"
4+
main: com.mefrreex.jooq.JOOQConnectorJukeboxMC

plugin-waterdogpe/build.gradle.kts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
plugins {
2+
id("java")
3+
id("com.github.johnrengelman.shadow") version "8.1.1"
4+
}
5+
6+
repositories {
7+
mavenCentral()
8+
maven("https://repo.waterdog.dev/main")
9+
maven("https://repo.opencollab.dev/maven-releases")
10+
maven("https://repo.opencollab.dev/maven-snapshots")
11+
}
12+
13+
dependencies {
14+
compileOnlyApi("dev.waterdog.waterdogpe:waterdog:2.0.0-SNAPSHOT")
15+
api(project(":api"))
16+
}
17+
18+
tasks.withType<Jar> {
19+
archiveFileName.set("JOOQConnector-WaterdogPE-${project.version}.jar")
20+
}
21+
22+
tasks.build {
23+
dependsOn(tasks.shadowJar)
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.mefrreex.jooq;
2+
3+
import dev.waterdog.waterdogpe.plugin.Plugin;
4+
5+
public class JOOQConnectorWaterdogPE extends Plugin {
6+
7+
@Override
8+
public void onStartup() {
9+
JOOQConnector.setJOOQMessagesEnabled(false);
10+
}
11+
12+
@Override
13+
public void onEnable() {
14+
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: "JOOQConnector"
2+
version: "${project.version}"
3+
author: "MEFRREEX"
4+
main: com.mefrreex.jooq.JOOQConnectorWaterdogPE

settings.gradle.kts

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ rootProject.name = "JOOQConnector"
33
include("api")
44
include("plugin-nukkit")
55
include("plugin-pnx")
6+
include("plugin-jukeboxmc")
7+
include("plugin-waterdogpe")

0 commit comments

Comments
 (0)