mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Fix some problems find some others
This commit is contained in:
1 parent
8286f91061
commit
6cbabd692e
10 files changed
+54
-29
No files matched your search
@@ -26,6 +26,8 @@ fun ShadowJar.standardRelocations() {
|
||||
relocateDependency("com.google.thirdparty.publicsuffix")
|
||||
relocateDependency("it.unimi.dsi.fastutil")
|
||||
relocateDependency("org.flywaydb")
|
||||
relocateDependency("org.jdbi")
|
||||
relocateDependency("com.github.benmanes")
|
||||
}
|
||||
|
||||
fun ShadowJar.relocateCloud() {
|
||||
@@ -39,7 +41,7 @@ fun ShadowJar.relocateGuice() {
|
||||
}
|
||||
|
||||
fun ShadowJar.configureShadowJar() {
|
||||
minimize()
|
||||
//minimize()
|
||||
standardRelocations()
|
||||
dependencies {
|
||||
// not needed at runtime
|
||||
|
||||
@@ -30,4 +30,6 @@ dependencies {
|
||||
api(libs.flyway)
|
||||
api(libs.flywayMysql)
|
||||
api(libs.mysql)
|
||||
api(libs.caffeine)
|
||||
api(libs.mariadb)
|
||||
}
|
||||
@@ -26,6 +26,7 @@ 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;
|
||||
@@ -64,7 +65,7 @@ public final class CarbonCommonModule extends AbstractModule {
|
||||
switch (Objects.requireNonNull(configFactory.primaryConfig()).storageType()) {
|
||||
case MYSQL -> {
|
||||
final UserManager<CarbonPlayerCommon> userManager = MariaDBUserManager.manager(
|
||||
configFactory.primaryConfig().databaseSettings(), this.getClass().getClassLoader());
|
||||
configFactory.primaryConfig().databaseSettings());
|
||||
|
||||
if (userManager == null) {
|
||||
throw new IllegalStateException("Failure connecting to database.");
|
||||
|
||||
@@ -40,27 +40,27 @@ public class MariaDBUserManager implements UserManager<CarbonPlayerCommon> {
|
||||
}
|
||||
|
||||
public static MariaDBUserManager manager(
|
||||
final DatabaseSettings databaseSettings,
|
||||
final ClassLoader classLoader
|
||||
final DatabaseSettings databaseSettings
|
||||
) {
|
||||
// final HikariConfig hikariConfig = new HikariConfig();
|
||||
// hikariConfig.setJdbcUrl(databaseSettings.url());
|
||||
// hikariConfig.setUsername(databaseSettings.username());
|
||||
// hikariConfig.setPassword(databaseSettings.password());
|
||||
//
|
||||
// final DataSource dataSource = new HikariDataSource(hikariConfig);
|
||||
final HikariConfig hikariConfig = new HikariConfig();
|
||||
hikariConfig.setMaximumPoolSize(20);
|
||||
hikariConfig.setDriverClassName("org.mariadb.jdbc.Driver");
|
||||
hikariConfig.setJdbcUrl(databaseSettings.url());
|
||||
hikariConfig.setUsername(databaseSettings.username());
|
||||
hikariConfig.setPassword(databaseSettings.password());
|
||||
|
||||
Flyway.configure(classLoader)
|
||||
final DataSource dataSource = new HikariDataSource(hikariConfig);
|
||||
|
||||
Flyway.configure(CarbonChatProvider.carbonChat().getClass().getClassLoader())
|
||||
.baselineVersion("0")
|
||||
.baselineOnMigrate(true)
|
||||
.locations("queries/migrations")
|
||||
.dataSource(databaseSettings.url(), databaseSettings.username(), databaseSettings.password())
|
||||
//.dataSource(dataSource)
|
||||
.dataSource(dataSource)
|
||||
.validateOnMigrate(true)
|
||||
.load()
|
||||
.migrate();
|
||||
|
||||
final Jdbi jdbi = Jdbi.create(databaseSettings.url(), databaseSettings.username(), databaseSettings.password())
|
||||
final Jdbi jdbi = Jdbi.create(dataSource)
|
||||
.registerArrayType(UUID.class, "uuid")
|
||||
.registerArgument(new UUIDArgumentFactory())
|
||||
.registerColumnMapper(Component.class, new ComponentMapper())
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
CREATE TABLE carbon_users (
|
||||
`id` UUID NOT NULL PRIMARY KEY,
|
||||
`id` BINARY(16) NOT NULL PRIMARY KEY,
|
||||
`muted` BOOLEAN,
|
||||
`deafened` BOOLEAN,
|
||||
`selectedchannel` varchar(256),
|
||||
`username` varchar(20),
|
||||
`displayname` varchar(1024),
|
||||
`lastwhispertarget` UUID,
|
||||
`whisperreplytarget` UUID,
|
||||
`lastwhispertarget` BINARY(16),
|
||||
`whisperreplytarget` BINARY(16),
|
||||
`spying` BOOLEAN
|
||||
);
|
||||
|
||||
CREATE TABLE carbon_ignores (
|
||||
`id` UUID NOT NULL,
|
||||
`ignoredplayer` UUID NOT NULL,
|
||||
`id` BINARY(16) NOT NULL,
|
||||
`ignoredplayer` BINARY(16) NOT NULL,
|
||||
PRIMARY KEY (id, ignoredplayer)
|
||||
);
|
||||
@@ -1,11 +1,11 @@
|
||||
INSERT INTO carbon_users VALUES (
|
||||
:uuid,
|
||||
UUID_TO_BIN(:id),
|
||||
:muted,
|
||||
:deafened,
|
||||
:selectedchannel,
|
||||
:username,
|
||||
:displayname,
|
||||
:lastwhispertarget,
|
||||
:whisperreplytarget,
|
||||
UUID_TO_BIN(:lastwhispertarget),
|
||||
UUID_TO_BIN(:whisperreplytarget),
|
||||
:spying
|
||||
);
|
||||
@@ -1 +1 @@
|
||||
INSERT INTO carbon_ignores (id, ignoredplayer) VALUES(:id, :name)
|
||||
INSERT INTO carbon_ignores (id, ignoredplayer) VALUES(UUID_TO_BIN(:id), :name)
|
||||
@@ -1,12 +1,12 @@
|
||||
UPDATE carbon_users
|
||||
SET
|
||||
id = :id,
|
||||
id = UUID_TO_BIN(:id),
|
||||
muted = :muted,
|
||||
deafened = :deafened,
|
||||
selectedchannel = :selectedchannel,
|
||||
username= :username,
|
||||
displayname = :displayname,
|
||||
lastwhispertarget = :lastwhispertarget,
|
||||
whisperreplytarget = :whisperreplytarget,
|
||||
lastwhispertarget = UUID_TO_BIN(:lastwhispertarget),
|
||||
whisperreplytarget = UUID_TO_BIN(:whisperreplytarget),
|
||||
spying = :spying
|
||||
WHERE id = :id;
|
||||
WHERE id = UUID_TO_BIN(:id);
|
||||
@@ -1 +1,11 @@
|
||||
SELECT * from carbon_users WHERE (id = :id);
|
||||
SELECT
|
||||
BIN_TO_UUID(id) id,
|
||||
muted,
|
||||
deafened,
|
||||
selectedchannel,
|
||||
username,
|
||||
displayname,
|
||||
UUID_TO_BIN(lastwhispertarget) lastwhispertarget,
|
||||
UUID_TO_BIN(whisperreplytarget) whisperreplytarget,
|
||||
spying
|
||||
from carbon_users WHERE (id = UUID_TO_BIN(:id));
|
||||
@@ -40,7 +40,9 @@ versions:
|
||||
jdbi: 3.25.0
|
||||
hikari: 5.0.0
|
||||
mysql: 8.0.12
|
||||
flyway: 8.2.3
|
||||
flyway: 8.3.0
|
||||
caffeine: 3.0.5
|
||||
mariadb: 3.0.2-rc
|
||||
|
||||
dependencies:
|
||||
adventureBom:
|
||||
@@ -199,6 +201,14 @@ dependencies:
|
||||
group: mysql
|
||||
name: mysql-connector-java
|
||||
version: { ref: mysql }
|
||||
caffeine:
|
||||
group: com.github.ben-manes.caffeine
|
||||
name: caffeine
|
||||
version: { ref: caffeine }
|
||||
mariadb:
|
||||
group: org.mariadb.jdbc
|
||||
name: mariadb-java-client
|
||||
version: { ref: mariadb }
|
||||
|
||||
paperApi:
|
||||
group: io.papermc.paper
|
||||
|
||||
Reference in new issue
Block a user