mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
it runs!
This commit is contained in:
1 parent
6cbabd692e
commit
9903e0da2c
15 files changed
+165
-21
No files matched your search
@@ -28,7 +28,7 @@ dependencies {
|
|||||||
api(libs.jdbiObject)
|
api(libs.jdbiObject)
|
||||||
api(libs.hikariCP)
|
api(libs.hikariCP)
|
||||||
api(libs.flyway)
|
api(libs.flyway)
|
||||||
api(libs.flywayMysql)
|
//api(libs.flywayMysql)
|
||||||
api(libs.mysql)
|
api(libs.mysql)
|
||||||
api(libs.caffeine)
|
api(libs.caffeine)
|
||||||
api(libs.mariadb)
|
api(libs.mariadb)
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ 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;
|
||||||
|
|||||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package net.draycia.carbon.common.config;
|
package net.draycia.carbon.common.config;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|||||||
+20
-1
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package net.draycia.carbon.common.users.db;
|
package net.draycia.carbon.common.users.db;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -12,7 +31,7 @@ import org.jdbi.v3.core.statement.StatementContext;
|
|||||||
public class CarbonPlayerCommonRowMapper implements RowMapper<CarbonPlayerCommon> {
|
public class CarbonPlayerCommonRowMapper implements RowMapper<CarbonPlayerCommon> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CarbonPlayerCommon map(ResultSet rs, StatementContext ctx) throws SQLException {
|
public CarbonPlayerCommon map(final ResultSet rs, final StatementContext ctx) throws SQLException {
|
||||||
return new CarbonPlayerCommon(
|
return new CarbonPlayerCommon(
|
||||||
rs.getBoolean("muted"),
|
rs.getBoolean("muted"),
|
||||||
rs.getBoolean("deafened"),
|
rs.getBoolean("deafened"),
|
||||||
|
|||||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package net.draycia.carbon.common.users.db;
|
package net.draycia.carbon.common.users.db;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
|||||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package net.draycia.carbon.common.users.db;
|
package net.draycia.carbon.common.users.db;
|
||||||
|
|
||||||
public final class DBType {
|
public final class DBType {
|
||||||
|
|||||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package net.draycia.carbon.common.users.db;
|
package net.draycia.carbon.common.users.db;
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
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.Jdbi;
|
||||||
import org.jdbi.v3.core.statement.PreparedBatch;
|
import org.jdbi.v3.core.statement.PreparedBatch;
|
||||||
import org.jdbi.v3.core.statement.Update;
|
import org.jdbi.v3.core.statement.Update;
|
||||||
|
|
||||||
import static net.kyori.adventure.text.Component.empty;
|
import static net.kyori.adventure.text.Component.empty;
|
||||||
import static net.kyori.adventure.text.Component.text;
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
// TODO: Dispatch updates using messaging system when users are modified
|
// TODO: Dispatch updates using messaging system when users are modified
|
||||||
@DefaultQualifier(NonNull.class)
|
@DefaultQualifier(NonNull.class)
|
||||||
public class MariaDBUserManager implements UserManager<CarbonPlayerCommon> {
|
public final class MariaDBUserManager implements UserManager<CarbonPlayerCommon> {
|
||||||
|
|
||||||
private final Jdbi jdbi;
|
private final Jdbi jdbi;
|
||||||
|
|
||||||
@@ -54,7 +74,7 @@ public class MariaDBUserManager implements UserManager<CarbonPlayerCommon> {
|
|||||||
Flyway.configure(CarbonChatProvider.carbonChat().getClass().getClassLoader())
|
Flyway.configure(CarbonChatProvider.carbonChat().getClass().getClassLoader())
|
||||||
.baselineVersion("0")
|
.baselineVersion("0")
|
||||||
.baselineOnMigrate(true)
|
.baselineOnMigrate(true)
|
||||||
.locations("queries/migrations")
|
.locations("queries/migrations/sql")
|
||||||
.dataSource(dataSource)
|
.dataSource(dataSource)
|
||||||
.validateOnMigrate(true)
|
.validateOnMigrate(true)
|
||||||
.load()
|
.load()
|
||||||
|
|||||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package net.draycia.carbon.common.users.db;
|
package net.draycia.carbon.common.users.db;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import java.util.List;
|
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.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.jdbi.v3.core.locator.ClasspathSqlLocator;
|
import org.jdbi.v3.core.locator.ClasspathSqlLocator;
|
||||||
|
import org.jdbi.v3.core.locator.internal.ClasspathBuilder;
|
||||||
|
|
||||||
public final class QueriesLocator {
|
public final class QueriesLocator {
|
||||||
|
|
||||||
@@ -16,11 +38,20 @@ public final class QueriesLocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public @NonNull String query(final @NonNull String name) {
|
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) {
|
public @NonNull List<@NonNull String> queries(final @NonNull String name) {
|
||||||
return SPLITTER.splitToList(this.locator.locate(this.dbType.basePath() + 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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* CarbonChat
|
* CarbonChat
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021 Josh Taylor (broccolai)
|
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||||
* Contributors
|
* Contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
INSERT INTO carbon_users VALUES (
|
INSERT INTO carbon_users VALUES (
|
||||||
UUID_TO_BIN(:id),
|
UNHEX(REPLACE(:id, '-', '')),
|
||||||
:muted,
|
:muted,
|
||||||
:deafened,
|
:deafened,
|
||||||
:selectedchannel,
|
:selectedchannel,
|
||||||
:username,
|
:username,
|
||||||
:displayname,
|
:displayname,
|
||||||
UUID_TO_BIN(:lastwhispertarget),
|
UNHEX(REPLACE(:lastwhispertarget, '-', '')),
|
||||||
UUID_TO_BIN(:whisperreplytarget),
|
UNHEX(REPLACE(:whisperreplytarget, '-', '')),
|
||||||
:spying
|
:spying
|
||||||
);
|
);
|
||||||
@@ -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, '-', '')))
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
UPDATE carbon_users
|
UPDATE carbon_users
|
||||||
SET
|
SET
|
||||||
id = UUID_TO_BIN(:id),
|
id = UNHEX(REPLACE(:id, '-', '')),
|
||||||
muted = :muted,
|
muted = :muted,
|
||||||
deafened = :deafened,
|
deafened = :deafened,
|
||||||
selectedchannel = :selectedchannel,
|
selectedchannel = :selectedchannel,
|
||||||
username= :username,
|
username= :username,
|
||||||
displayname = :displayname,
|
displayname = :displayname,
|
||||||
lastwhispertarget = UUID_TO_BIN(:lastwhispertarget),
|
lastwhispertarget = UNHEX(REPLACE(:lastwhispertarget, '-', '')),
|
||||||
whisperreplytarget = UUID_TO_BIN(:whisperreplytarget),
|
whisperreplytarget = UNHEX(REPLACE(:whisperreplytarget, '-', '')),
|
||||||
spying = :spying
|
spying = :spying
|
||||||
WHERE id = UUID_TO_BIN(:id);
|
WHERE id = UNHEX(REPLACE(:id, '-', ''));
|
||||||
@@ -1 +1 @@
|
|||||||
SELECT ignoredplayer FROM carbon_ignores WHERE (id = :id);
|
SELECT ignoredplayer FROM carbon_ignores WHERE (id = UNHEX(REPLACE(:id, '-', '')));
|
||||||
@@ -1,11 +1,29 @@
|
|||||||
SELECT
|
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,
|
muted,
|
||||||
deafened,
|
deafened,
|
||||||
selectedchannel,
|
selectedchannel,
|
||||||
username,
|
username,
|
||||||
displayname,
|
displayname,
|
||||||
UUID_TO_BIN(lastwhispertarget) lastwhispertarget,
|
LOWER(CONCAT(
|
||||||
UUID_TO_BIN(whisperreplytarget) whisperreplytarget,
|
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
|
spying
|
||||||
from carbon_users WHERE (id = UUID_TO_BIN(:id));
|
FROM carbon_users WHERE (id = UNHEX(REPLACE(:id, '-', '')));
|
||||||
@@ -40,7 +40,7 @@ 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.3.0
|
flyway: 7.7.1
|
||||||
caffeine: 3.0.5
|
caffeine: 3.0.5
|
||||||
mariadb: 3.0.2-rc
|
mariadb: 3.0.2-rc
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user