This commit is contained in:
Draycia committed 2022-06-08 15:16:19 -07:00
1 parent 6cbabd692e
commit 9903e0da2c
15 files changed
+165 -21

No files matched your search

@@ -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;
@@ -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;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -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;
import java.sql.ResultSet;
@@ -12,7 +31,7 @@ import org.jdbi.v3.core.statement.StatementContext;
public class CarbonPlayerCommonRowMapper implements RowMapper<CarbonPlayerCommon> {
@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"),
@@ -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;
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;
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;
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<CarbonPlayerCommon> {
public final class MariaDBUserManager implements UserManager<CarbonPlayerCommon> {
private final Jdbi jdbi;
@@ -54,7 +74,7 @@ public class MariaDBUserManager implements UserManager<CarbonPlayerCommon> {
Flyway.configure(CarbonChatProvider.carbonChat().getClass().getClassLoader())
.baselineVersion("0")
.baselineOnMigrate(true)
.locations("queries/migrations")
.locations("queries/migrations/sql")
.dataSource(dataSource)
.validateOnMigrate(true)
.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;
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());
}
}
@@ -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