mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +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("com.google.thirdparty.publicsuffix")
|
||||||
relocateDependency("it.unimi.dsi.fastutil")
|
relocateDependency("it.unimi.dsi.fastutil")
|
||||||
relocateDependency("org.flywaydb")
|
relocateDependency("org.flywaydb")
|
||||||
|
relocateDependency("org.jdbi")
|
||||||
|
relocateDependency("com.github.benmanes")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ShadowJar.relocateCloud() {
|
fun ShadowJar.relocateCloud() {
|
||||||
@@ -39,7 +41,7 @@ fun ShadowJar.relocateGuice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun ShadowJar.configureShadowJar() {
|
fun ShadowJar.configureShadowJar() {
|
||||||
minimize()
|
//minimize()
|
||||||
standardRelocations()
|
standardRelocations()
|
||||||
dependencies {
|
dependencies {
|
||||||
// not needed at runtime
|
// not needed at runtime
|
||||||
|
|||||||
@@ -30,4 +30,6 @@ dependencies {
|
|||||||
api(libs.flyway)
|
api(libs.flyway)
|
||||||
api(libs.flywayMysql)
|
api(libs.flywayMysql)
|
||||||
api(libs.mysql)
|
api(libs.mysql)
|
||||||
|
api(libs.caffeine)
|
||||||
|
api(libs.mariadb)
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ import com.google.inject.Singleton;
|
|||||||
import io.leangen.geantyref.TypeToken;
|
import io.leangen.geantyref.TypeToken;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import net.draycia.carbon.api.CarbonChat;
|
||||||
import net.draycia.carbon.api.CarbonChatProvider;
|
import net.draycia.carbon.api.CarbonChatProvider;
|
||||||
import net.draycia.carbon.api.channels.ChannelRegistry;
|
import net.draycia.carbon.api.channels.ChannelRegistry;
|
||||||
import net.draycia.carbon.api.users.UserManager;
|
import net.draycia.carbon.api.users.UserManager;
|
||||||
@@ -64,7 +65,7 @@ public final class CarbonCommonModule extends AbstractModule {
|
|||||||
switch (Objects.requireNonNull(configFactory.primaryConfig()).storageType()) {
|
switch (Objects.requireNonNull(configFactory.primaryConfig()).storageType()) {
|
||||||
case MYSQL -> {
|
case MYSQL -> {
|
||||||
final UserManager<CarbonPlayerCommon> userManager = MariaDBUserManager.manager(
|
final UserManager<CarbonPlayerCommon> userManager = MariaDBUserManager.manager(
|
||||||
configFactory.primaryConfig().databaseSettings(), this.getClass().getClassLoader());
|
configFactory.primaryConfig().databaseSettings());
|
||||||
|
|
||||||
if (userManager == null) {
|
if (userManager == null) {
|
||||||
throw new IllegalStateException("Failure connecting to database.");
|
throw new IllegalStateException("Failure connecting to database.");
|
||||||
|
|||||||
@@ -40,27 +40,27 @@ public class MariaDBUserManager implements UserManager<CarbonPlayerCommon> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MariaDBUserManager manager(
|
public static MariaDBUserManager manager(
|
||||||
final DatabaseSettings databaseSettings,
|
final DatabaseSettings databaseSettings
|
||||||
final ClassLoader classLoader
|
|
||||||
) {
|
) {
|
||||||
// final HikariConfig hikariConfig = new HikariConfig();
|
final HikariConfig hikariConfig = new HikariConfig();
|
||||||
// hikariConfig.setJdbcUrl(databaseSettings.url());
|
hikariConfig.setMaximumPoolSize(20);
|
||||||
// hikariConfig.setUsername(databaseSettings.username());
|
hikariConfig.setDriverClassName("org.mariadb.jdbc.Driver");
|
||||||
// hikariConfig.setPassword(databaseSettings.password());
|
hikariConfig.setJdbcUrl(databaseSettings.url());
|
||||||
//
|
hikariConfig.setUsername(databaseSettings.username());
|
||||||
// final DataSource dataSource = new HikariDataSource(hikariConfig);
|
hikariConfig.setPassword(databaseSettings.password());
|
||||||
|
|
||||||
Flyway.configure(classLoader)
|
final DataSource dataSource = new HikariDataSource(hikariConfig);
|
||||||
|
|
||||||
|
Flyway.configure(CarbonChatProvider.carbonChat().getClass().getClassLoader())
|
||||||
.baselineVersion("0")
|
.baselineVersion("0")
|
||||||
.baselineOnMigrate(true)
|
.baselineOnMigrate(true)
|
||||||
.locations("queries/migrations")
|
.locations("queries/migrations")
|
||||||
.dataSource(databaseSettings.url(), databaseSettings.username(), databaseSettings.password())
|
.dataSource(dataSource)
|
||||||
//.dataSource(dataSource)
|
|
||||||
.validateOnMigrate(true)
|
.validateOnMigrate(true)
|
||||||
.load()
|
.load()
|
||||||
.migrate();
|
.migrate();
|
||||||
|
|
||||||
final Jdbi jdbi = Jdbi.create(databaseSettings.url(), databaseSettings.username(), databaseSettings.password())
|
final Jdbi jdbi = Jdbi.create(dataSource)
|
||||||
.registerArrayType(UUID.class, "uuid")
|
.registerArrayType(UUID.class, "uuid")
|
||||||
.registerArgument(new UUIDArgumentFactory())
|
.registerArgument(new UUIDArgumentFactory())
|
||||||
.registerColumnMapper(Component.class, new ComponentMapper())
|
.registerColumnMapper(Component.class, new ComponentMapper())
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
CREATE TABLE carbon_users (
|
CREATE TABLE carbon_users (
|
||||||
`id` UUID NOT NULL PRIMARY KEY,
|
`id` BINARY(16) NOT NULL PRIMARY KEY,
|
||||||
`muted` BOOLEAN,
|
`muted` BOOLEAN,
|
||||||
`deafened` BOOLEAN,
|
`deafened` BOOLEAN,
|
||||||
`selectedchannel` varchar(256),
|
`selectedchannel` varchar(256),
|
||||||
`username` varchar(20),
|
`username` varchar(20),
|
||||||
`displayname` varchar(1024),
|
`displayname` varchar(1024),
|
||||||
`lastwhispertarget` UUID,
|
`lastwhispertarget` BINARY(16),
|
||||||
`whisperreplytarget` UUID,
|
`whisperreplytarget` BINARY(16),
|
||||||
`spying` BOOLEAN
|
`spying` BOOLEAN
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE carbon_ignores (
|
CREATE TABLE carbon_ignores (
|
||||||
`id` UUID NOT NULL,
|
`id` BINARY(16) NOT NULL,
|
||||||
`ignoredplayer` UUID NOT NULL,
|
`ignoredplayer` BINARY(16) NOT NULL,
|
||||||
PRIMARY KEY (id, ignoredplayer)
|
PRIMARY KEY (id, ignoredplayer)
|
||||||
);
|
);
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
INSERT INTO carbon_users VALUES (
|
INSERT INTO carbon_users VALUES (
|
||||||
:uuid,
|
UUID_TO_BIN(:id),
|
||||||
:muted,
|
:muted,
|
||||||
:deafened,
|
:deafened,
|
||||||
:selectedchannel,
|
:selectedchannel,
|
||||||
:username,
|
:username,
|
||||||
:displayname,
|
:displayname,
|
||||||
:lastwhispertarget,
|
UUID_TO_BIN(:lastwhispertarget),
|
||||||
:whisperreplytarget,
|
UUID_TO_BIN(:whisperreplytarget),
|
||||||
:spying
|
: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
|
UPDATE carbon_users
|
||||||
SET
|
SET
|
||||||
id = :id,
|
id = UUID_TO_BIN(:id),
|
||||||
muted = :muted,
|
muted = :muted,
|
||||||
deafened = :deafened,
|
deafened = :deafened,
|
||||||
selectedchannel = :selectedchannel,
|
selectedchannel = :selectedchannel,
|
||||||
username= :username,
|
username= :username,
|
||||||
displayname = :displayname,
|
displayname = :displayname,
|
||||||
lastwhispertarget = :lastwhispertarget,
|
lastwhispertarget = UUID_TO_BIN(:lastwhispertarget),
|
||||||
whisperreplytarget = :whisperreplytarget,
|
whisperreplytarget = UUID_TO_BIN(:whisperreplytarget),
|
||||||
spying = :spying
|
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
|
jdbi: 3.25.0
|
||||||
hikari: 5.0.0
|
hikari: 5.0.0
|
||||||
mysql: 8.0.12
|
mysql: 8.0.12
|
||||||
flyway: 8.2.3
|
flyway: 8.3.0
|
||||||
|
caffeine: 3.0.5
|
||||||
|
mariadb: 3.0.2-rc
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
adventureBom:
|
adventureBom:
|
||||||
@@ -199,6 +201,14 @@ dependencies:
|
|||||||
group: mysql
|
group: mysql
|
||||||
name: mysql-connector-java
|
name: mysql-connector-java
|
||||||
version: { ref: mysql }
|
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:
|
paperApi:
|
||||||
group: io.papermc.paper
|
group: io.papermc.paper
|
||||||
|
|||||||
Reference in new issue
Block a user