diff --git a/common/build.gradle.kts b/common/build.gradle.kts
index 00079a21..99a680ed 100644
--- a/common/build.gradle.kts
+++ b/common/build.gradle.kts
@@ -28,7 +28,7 @@ dependencies {
api(libs.jdbiObject)
api(libs.hikariCP)
api(libs.flyway)
- api(libs.flywayMysql)
+ //api(libs.flywayMysql)
api(libs.mysql)
api(libs.caffeine)
api(libs.mariadb)
diff --git a/common/src/main/java/net/draycia/carbon/common/CarbonCommonModule.java b/common/src/main/java/net/draycia/carbon/common/CarbonCommonModule.java
index 9b5d5ff3..0f947ff1 100644
--- a/common/src/main/java/net/draycia/carbon/common/CarbonCommonModule.java
+++ b/common/src/main/java/net/draycia/carbon/common/CarbonCommonModule.java
@@ -26,7 +26,6 @@ import com.google.inject.Singleton;
import io.leangen.geantyref.TypeToken;
import java.util.Objects;
import java.util.UUID;
-import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.api.CarbonChatProvider;
import net.draycia.carbon.api.channels.ChannelRegistry;
import net.draycia.carbon.api.users.UserManager;
diff --git a/common/src/main/java/net/draycia/carbon/common/config/DatabaseSettings.java b/common/src/main/java/net/draycia/carbon/common/config/DatabaseSettings.java
index 6c43f8e9..2c2d6a57 100644
--- a/common/src/main/java/net/draycia/carbon/common/config/DatabaseSettings.java
+++ b/common/src/main/java/net/draycia/carbon/common/config/DatabaseSettings.java
@@ -1,3 +1,22 @@
+/*
+ * CarbonChat
+ *
+ * Copyright (c) 2021 Josua Parks (Vicarious)
+ * Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package net.draycia.carbon.common.config;
import org.checkerframework.checker.nullness.qual.Nullable;
diff --git a/common/src/main/java/net/draycia/carbon/common/users/db/CarbonPlayerCommonRowMapper.java b/common/src/main/java/net/draycia/carbon/common/users/db/CarbonPlayerCommonRowMapper.java
index 652a5d1c..67fca2a2 100644
--- a/common/src/main/java/net/draycia/carbon/common/users/db/CarbonPlayerCommonRowMapper.java
+++ b/common/src/main/java/net/draycia/carbon/common/users/db/CarbonPlayerCommonRowMapper.java
@@ -1,3 +1,22 @@
+/*
+ * CarbonChat
+ *
+ * Copyright (c) 2021 Josua Parks (Vicarious)
+ * Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package net.draycia.carbon.common.users.db;
import java.sql.ResultSet;
@@ -12,7 +31,7 @@ import org.jdbi.v3.core.statement.StatementContext;
public class CarbonPlayerCommonRowMapper implements RowMapper {
@Override
- public CarbonPlayerCommon map(ResultSet rs, StatementContext ctx) throws SQLException {
+ public CarbonPlayerCommon map(final ResultSet rs, final StatementContext ctx) throws SQLException {
return new CarbonPlayerCommon(
rs.getBoolean("muted"),
rs.getBoolean("deafened"),
diff --git a/common/src/main/java/net/draycia/carbon/common/users/db/ComponentMapper.java b/common/src/main/java/net/draycia/carbon/common/users/db/ComponentMapper.java
index fa16e01b..550025e1 100644
--- a/common/src/main/java/net/draycia/carbon/common/users/db/ComponentMapper.java
+++ b/common/src/main/java/net/draycia/carbon/common/users/db/ComponentMapper.java
@@ -1,3 +1,22 @@
+/*
+ * CarbonChat
+ *
+ * Copyright (c) 2021 Josua Parks (Vicarious)
+ * Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package net.draycia.carbon.common.users.db;
import java.sql.ResultSet;
diff --git a/common/src/main/java/net/draycia/carbon/common/users/db/DBType.java b/common/src/main/java/net/draycia/carbon/common/users/db/DBType.java
index ad81d879..7735f5af 100644
--- a/common/src/main/java/net/draycia/carbon/common/users/db/DBType.java
+++ b/common/src/main/java/net/draycia/carbon/common/users/db/DBType.java
@@ -1,3 +1,22 @@
+/*
+ * CarbonChat
+ *
+ * Copyright (c) 2021 Josua Parks (Vicarious)
+ * Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package net.draycia.carbon.common.users.db;
public final class DBType {
diff --git a/common/src/main/java/net/draycia/carbon/common/users/db/MariaDBUserManager.java b/common/src/main/java/net/draycia/carbon/common/users/db/MariaDBUserManager.java
index 6816eae3..75fe6a2c 100644
--- a/common/src/main/java/net/draycia/carbon/common/users/db/MariaDBUserManager.java
+++ b/common/src/main/java/net/draycia/carbon/common/users/db/MariaDBUserManager.java
@@ -1,3 +1,22 @@
+/*
+ * CarbonChat
+ *
+ * Copyright (c) 2021 Josua Parks (Vicarious)
+ * Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package net.draycia.carbon.common.users.db;
import com.zaxxer.hikari.HikariConfig;
@@ -23,12 +42,13 @@ import org.flywaydb.core.Flyway;
import org.jdbi.v3.core.Jdbi;
import org.jdbi.v3.core.statement.PreparedBatch;
import org.jdbi.v3.core.statement.Update;
+
import static net.kyori.adventure.text.Component.empty;
import static net.kyori.adventure.text.Component.text;
// TODO: Dispatch updates using messaging system when users are modified
@DefaultQualifier(NonNull.class)
-public class MariaDBUserManager implements UserManager {
+public final class MariaDBUserManager implements UserManager {
private final Jdbi jdbi;
@@ -54,7 +74,7 @@ public class MariaDBUserManager implements UserManager {
Flyway.configure(CarbonChatProvider.carbonChat().getClass().getClassLoader())
.baselineVersion("0")
.baselineOnMigrate(true)
- .locations("queries/migrations")
+ .locations("queries/migrations/sql")
.dataSource(dataSource)
.validateOnMigrate(true)
.load()
diff --git a/common/src/main/java/net/draycia/carbon/common/users/db/QueriesLocator.java b/common/src/main/java/net/draycia/carbon/common/users/db/QueriesLocator.java
index 74a5c419..abe05bb7 100644
--- a/common/src/main/java/net/draycia/carbon/common/users/db/QueriesLocator.java
+++ b/common/src/main/java/net/draycia/carbon/common/users/db/QueriesLocator.java
@@ -1,9 +1,31 @@
+/*
+ * CarbonChat
+ *
+ * Copyright (c) 2021 Josua Parks (Vicarious)
+ * Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
package net.draycia.carbon.common.users.db;
import com.google.common.base.Splitter;
import java.util.List;
+import net.draycia.carbon.api.CarbonChat;
+import net.draycia.carbon.api.CarbonChatProvider;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jdbi.v3.core.locator.ClasspathSqlLocator;
+import org.jdbi.v3.core.locator.internal.ClasspathBuilder;
public final class QueriesLocator {
@@ -16,11 +38,20 @@ public final class QueriesLocator {
}
public @NonNull String query(final @NonNull String name) {
- return this.locator.locate(this.dbType.basePath() + name);
+ return this.locate(this.dbType.basePath() + name);
}
public @NonNull List<@NonNull String> queries(final @NonNull String name) {
return SPLITTER.splitToList(this.locator.locate(this.dbType.basePath() + name));
}
+ private String locate(final String name) {
+ return locator.getResource(
+ CarbonChat.class.getClassLoader(),
+ new ClasspathBuilder()
+ .appendDotPath(name)
+ .setExtension("sql")
+ .build());
+ }
+
}
diff --git a/common/src/main/java/net/draycia/carbon/common/users/db/UUIDArgumentFactory.java b/common/src/main/java/net/draycia/carbon/common/users/db/UUIDArgumentFactory.java
index dc09540b..02c44a52 100644
--- a/common/src/main/java/net/draycia/carbon/common/users/db/UUIDArgumentFactory.java
+++ b/common/src/main/java/net/draycia/carbon/common/users/db/UUIDArgumentFactory.java
@@ -1,7 +1,7 @@
/*
* CarbonChat
*
- * Copyright (c) 2021 Josh Taylor (broccolai)
+ * Copyright (c) 2021 Josua Parks (Vicarious)
* Contributors
*
* This program is free software: you can redistribute it and/or modify
diff --git a/common/src/main/resources/queries/sql/insert-player.sql b/common/src/main/resources/queries/sql/insert-player.sql
index 2c2073f5..31db729c 100644
--- a/common/src/main/resources/queries/sql/insert-player.sql
+++ b/common/src/main/resources/queries/sql/insert-player.sql
@@ -1,11 +1,11 @@
INSERT INTO carbon_users VALUES (
- UUID_TO_BIN(:id),
+ UNHEX(REPLACE(:id, '-', '')),
:muted,
:deafened,
:selectedchannel,
:username,
:displayname,
- UUID_TO_BIN(:lastwhispertarget),
- UUID_TO_BIN(:whisperreplytarget),
+ UNHEX(REPLACE(:lastwhispertarget, '-', '')),
+ UNHEX(REPLACE(:whisperreplytarget, '-', '')),
:spying
);
diff --git a/common/src/main/resources/queries/sql/save-ignores.sql b/common/src/main/resources/queries/sql/save-ignores.sql
index d711e208..712fdd89 100644
--- a/common/src/main/resources/queries/sql/save-ignores.sql
+++ b/common/src/main/resources/queries/sql/save-ignores.sql
@@ -1 +1 @@
-INSERT INTO carbon_ignores (id, ignoredplayer) VALUES(UUID_TO_BIN(:id), :name)
+INSERT INTO carbon_ignores (id, ignoredplayer) VALUES(UNHEX(REPLACE(:id, '-', '')), UNHEX(REPLACE(:ignoredplayer, '-', '')))
diff --git a/common/src/main/resources/queries/sql/save-player.sql b/common/src/main/resources/queries/sql/save-player.sql
index 37dc1ed8..b6badb3e 100644
--- a/common/src/main/resources/queries/sql/save-player.sql
+++ b/common/src/main/resources/queries/sql/save-player.sql
@@ -1,12 +1,12 @@
UPDATE carbon_users
SET
- id = UUID_TO_BIN(:id),
+ id = UNHEX(REPLACE(:id, '-', '')),
muted = :muted,
deafened = :deafened,
selectedchannel = :selectedchannel,
username= :username,
displayname = :displayname,
- lastwhispertarget = UUID_TO_BIN(:lastwhispertarget),
- whisperreplytarget = UUID_TO_BIN(:whisperreplytarget),
+ lastwhispertarget = UNHEX(REPLACE(:lastwhispertarget, '-', '')),
+ whisperreplytarget = UNHEX(REPLACE(:whisperreplytarget, '-', '')),
spying = :spying
-WHERE id = UUID_TO_BIN(:id);
+WHERE id = UNHEX(REPLACE(:id, '-', ''));
diff --git a/common/src/main/resources/queries/sql/select-ignores.sql b/common/src/main/resources/queries/sql/select-ignores.sql
index 54948c76..80982b25 100644
--- a/common/src/main/resources/queries/sql/select-ignores.sql
+++ b/common/src/main/resources/queries/sql/select-ignores.sql
@@ -1 +1 @@
-SELECT ignoredplayer FROM carbon_ignores WHERE (id = :id);
+SELECT ignoredplayer FROM carbon_ignores WHERE (id = UNHEX(REPLACE(:id, '-', '')));
diff --git a/common/src/main/resources/queries/sql/select-player.sql b/common/src/main/resources/queries/sql/select-player.sql
index eb8d3c33..4ba65bfc 100644
--- a/common/src/main/resources/queries/sql/select-player.sql
+++ b/common/src/main/resources/queries/sql/select-player.sql
@@ -1,11 +1,29 @@
SELECT
- BIN_TO_UUID(id) id,
+ LOWER(CONCAT(
+ LEFT(HEX(id), 8), '-',
+ MID(HEX(id), 9, 4), '-',
+ MID(HEX(id), 13, 4), '-',
+ MID(HEX(id), 17, 4), '-',
+ RIGHT(HEX(id), 12)
+ )) AS id,
muted,
deafened,
selectedchannel,
username,
displayname,
- UUID_TO_BIN(lastwhispertarget) lastwhispertarget,
- UUID_TO_BIN(whisperreplytarget) whisperreplytarget,
+ LOWER(CONCAT(
+ LEFT(HEX(lastwhispertarget), 8), '-',
+ MID(HEX(lastwhispertarget), 9, 4), '-',
+ MID(HEX(lastwhispertarget), 13, 4), '-',
+ MID(HEX(lastwhispertarget), 17, 4), '-',
+ RIGHT(HEX(lastwhispertarget), 12)
+ )) AS lastwhispertarget,
+ LOWER(CONCAT(
+ LEFT(HEX(whisperreplytarget), 8), '-',
+ MID(HEX(whisperreplytarget), 9, 4), '-',
+ MID(HEX(whisperreplytarget), 13, 4), '-',
+ MID(HEX(whisperreplytarget), 17, 4), '-',
+ RIGHT(HEX(whisperreplytarget), 12)
+ )) AS whisperreplytarget,
spying
-from carbon_users WHERE (id = UUID_TO_BIN(:id));
+FROM carbon_users WHERE (id = UNHEX(REPLACE(:id, '-', '')));
diff --git a/gradle/libs.versions.yml b/gradle/libs.versions.yml
index 2733fdbb..b6f42f0d 100644
--- a/gradle/libs.versions.yml
+++ b/gradle/libs.versions.yml
@@ -40,7 +40,7 @@ versions:
jdbi: 3.25.0
hikari: 5.0.0
mysql: 8.0.12
- flyway: 8.3.0
+ flyway: 7.7.1
caffeine: 3.0.5
mariadb: 3.0.2-rc