Skip to content

Commit 77f90da

Browse files
committed
Fix breaking changes and dependencies
1 parent 1d4380a commit 77f90da

File tree

15 files changed

+88
-30
lines changed

15 files changed

+88
-30
lines changed

api/src/main/kotlin/org/anvilpowered/catalyst/api/user/MinecraftUser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import java.util.UUID
2929
* Represents a single user of a game.
3030
*/
3131
data class MinecraftUser(
32-
override val id: UUID,
32+
override val uuid: UUID,
3333
val username: String,
3434
val ipAddress: String,
3535
val nickname: String? = null,

api/src/main/kotlin/org/anvilpowered/catalyst/api/user/MinecraftUserRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package org.anvilpowered.catalyst.api.user
2020

2121
import com.velocitypowered.api.proxy.Player
2222
import org.anvilpowered.anvil.core.db.MutableRepository
23-
import org.jetbrains.exposed.sql.SizedIterable
23+
import org.anvilpowered.anvil.core.db.SizedIterable
2424
import java.util.UUID
2525

2626
interface MinecraftUserRepository : MutableRepository<MinecraftUser, MinecraftUser.CreateDto> {

api/src/main/kotlin/org/anvilpowered/catalyst/api/user/User.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import java.util.UUID
3030
* Represents a single universal user across all games and platforms.
3131
*/
3232
data class User(
33-
override val id: UUID,
33+
override val uuid: UUID,
3434
val username: String,
3535
val email: String? = null,
3636
val discordUserId: Long? = null,

build.gradle.kts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,18 @@ allprojects {
4545
}
4646
}
4747

48+
java {
49+
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
50+
}
51+
4852
tasks {
4953
withType<KotlinCompile> {
50-
kotlinOptions.jvmTarget = "17"
54+
kotlinOptions.jvmTarget = "21"
5155
}
5256
withType<JavaCompile> {
5357
options.encoding = "UTF-8"
54-
sourceCompatibility = "17"
55-
targetCompatibility = "17"
58+
sourceCompatibility = "21"
59+
targetCompatibility = "21"
5660
}
5761
}
5862
}

core/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
dependencies {
22
api(project(":catalyst-api"))
3-
runtimeOnly(libs.driver.mariadb)
3+
runtimeOnly(libs.driver.mariadb) {
4+
exclude(group = "org.slf4j")
5+
}
46
runtimeOnly(libs.driver.postgresql)
57
}

gradle/libs.versions.toml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
[versions]
22
anvil = "0.4.0-SNAPSHOT"
33
kotlin = "1.9.22"
4+
log4j = "2.23.1"
45

56
[libraries]
67
adventure-bom = "net.kyori:adventure-bom:4.16.0"
78
anvil-core = { module = "org.anvilpowered:anvil-core", version.ref = "anvil" }
89
anvil-velocity = { module = "org.anvilpowered:anvil-velocity", version.ref = "anvil" }
9-
brigadier = "com.mojang:brigadier:1.0.18"
1010
discord-jda = "net.dv8tion:JDA:5.0.0-beta.20"
1111
discord-webhooks = "club.minnced:discord-webhooks:0.8.4"
1212
driver-mariadb = "org.mariadb.jdbc:mariadb-java-client:3.3.2"
1313
driver-postgresql = "org.postgresql:postgresql:42.7.2"
14+
exposed-bom = "org.jetbrains.exposed:exposed-bom:0.50.1"
15+
exposed-core = { module = "org.jetbrains.exposed:exposed-core" }
16+
exposed-dao = { module = "org.jetbrains.exposed:exposed-dao" }
17+
exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc" }
18+
exposed-java-time = { module = "org.jetbrains.exposed:exposed-java-time" }
1419
kotest = "io.kotest:kotest-runner-junit5-jvm:5.8.0"
1520
kotlinx-serialization = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
21+
logging-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" }
22+
logging-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
1623
luckperms = "net.luckperms:api:5.4"
17-
velocity = "com.velocitypowered:velocity-api:3.1.1"
24+
velocity = "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT"
25+
26+
[bundles]
27+
exposed = ["exposed-core", "exposed-dao", "exposed-jdbc", "exposed-java-time"]
1828

1929
[plugins]
2030
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
2131
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
2232
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
2333
ktlint = "org.jlleitschuh.gradle.ktlint:11.6.1"
24-
shadow = "com.github.johnrengelman.shadow:8.1.1"
25-
sponge = "org.spongepowered.gradle.plugin:2.2.0"
34+
shadow = "io.github.goooler.shadow:8.1.7"

proxy/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ plugins {
44
}
55
dependencies {
66
api(libs.anvil.core)
7-
api(platform("net.kyori:adventure-bom:4.16.0"))
7+
8+
api(platform(libs.exposed.bom))
9+
api(libs.bundles.exposed) {
10+
exclude(group = "org.slf4j")
11+
}
12+
13+
api(platform(libs.adventure.bom))
814
api("net.kyori:adventure-text-serializer-legacy")
915
api("net.kyori:adventure-text-serializer-plain")
1016

proxy/src/main/kotlin/org/anvilpowered/catalyst/proxy/chat/builder/ChannelMessageBuilderImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ internal class ChannelMessageBuilderImpl(
4848
private var rawContent: Component? = null
4949

5050
override fun user(user: MinecraftUser): ChannelMessage.Builder {
51-
player = proxyServer.getPlayer(user.id)
52-
.orElseThrow { IllegalStateException("User ${user.username} with id ${user.id} is not on the server!") }
51+
player = proxyServer.getPlayer(user.uuid)
52+
.orElseThrow { IllegalStateException("User ${user.username} with id ${user.uuid} is not on the server!") }
5353
this.user = user
5454
return this
5555
}

proxy/src/main/kotlin/org/anvilpowered/catalyst/proxy/command/nickname/Delete.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fun NicknameCommandFactory.createDelete(): LiteralCommandNode<CommandSource> =
7373
.append(Component.text("You don't have permission to delete other players' nicknames!", NamedTextColor.RED)),
7474
)
7575
yieldError()
76-
} else if (minecraftUserRepository.deleteNickname(minecraftUser.id)) {
76+
} else if (minecraftUserRepository.deleteNickname(minecraftUser.uuid)) {
7777
context.source.sendMessage(
7878
PluginMessages.pluginPrefix
7979
.append(Component.text("The nickname of ", NamedTextColor.RED))

proxy/src/main/kotlin/org/anvilpowered/catalyst/proxy/command/nickname/Set.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fun NicknameCommandFactory.createSet(): LiteralCommandNode<CommandSource> =
7777
.append(Component.text("You don't have permission to set other players' nicknames!", NamedTextColor.RED)),
7878
)
7979
yieldError()
80-
} else if (minecraftUserRepository.updateNickname(minecraftUser.id, context["nickname"])) {
80+
} else if (minecraftUserRepository.updateNickname(minecraftUser.uuid, context["nickname"])) {
8181
context.source.sendMessage(
8282
PluginMessages.pluginPrefix
8383
.append(Component.text("The nickname of '", NamedTextColor.GRAY))
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* OnTime - AnvilPowered.org
3+
* Copyright (C) 2019-2024 Contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
package org.anvilpowered.catalyst.proxy.db
20+
21+
import org.anvilpowered.anvil.core.db.SizedIterable
22+
import org.anvilpowered.anvil.core.db.SizedIterable as AnvilSizedIterable
23+
import org.jetbrains.exposed.sql.SizedIterable as ExposedSizedIterable
24+
25+
fun <T> ExposedSizedIterable<T>.wrap(): SizedIterable<T> = SizedIterableWrapper(this)
26+
27+
private class SizedIterableWrapper<out T>(
28+
private val delegate: ExposedSizedIterable<T>,
29+
) : AnvilSizedIterable<T> {
30+
override fun copy(): SizedIterable<T> = SizedIterableWrapper(delegate.copy())
31+
override fun count(): Long = delegate.count()
32+
override fun empty(): Boolean = delegate.empty()
33+
override fun iterator(): Iterator<T> = delegate.iterator()
34+
override fun limit(n: Int, offset: Long): SizedIterable<T> = SizedIterableWrapper(delegate.limit(n, offset))
35+
}

proxy/src/main/kotlin/org/anvilpowered/catalyst/proxy/db/user/MinecraftUserRepositoryImpl.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@
1919
package org.anvilpowered.catalyst.proxy.db.user
2020

2121
import org.anvilpowered.anvil.core.db.MutableRepository
22+
import org.anvilpowered.anvil.core.db.SizedIterable
2223
import org.anvilpowered.catalyst.api.user.MinecraftUser
2324
import org.anvilpowered.catalyst.api.user.MinecraftUserRepository
2425
import org.anvilpowered.catalyst.api.user.User
26+
import org.anvilpowered.catalyst.proxy.db.wrap
2527
import org.apache.logging.log4j.Logger
26-
import org.jetbrains.exposed.sql.SizedIterable
2728
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
2829
import org.jetbrains.exposed.sql.deleteWhere
2930
import org.jetbrains.exposed.sql.mapLazy
3031
import org.jetbrains.exposed.sql.select
32+
import org.jetbrains.exposed.sql.selectAll
3133
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
3234
import org.jetbrains.exposed.sql.update
3335
import java.util.UUID
@@ -63,7 +65,7 @@ class MinecraftUserRepositoryImpl(
6365
minecraftUser = newUser
6466
}.let { User(it.id.value, item.username, minecraftUserId = item.id) }
6567

66-
logger.info("Created new MinecraftUser ${item.id} with data $item and accompanying User ${user.id}")
68+
logger.info("Created new MinecraftUser ${item.id} with data $item and accompanying User ${user.uuid}")
6769

6870
MutableRepository.PutResult(MinecraftUser(newUser.id.value, item.username, item.ipAddress), created = true)
6971
} else {
@@ -107,10 +109,10 @@ class MinecraftUserRepositoryImpl(
107109

108110
override suspend fun getAllUsernames(startWith: String): SizedIterable<String> = newSuspendedTransaction {
109111
MinecraftUserEntity.find { MinecraftUserTable.username like "$startWith%" }.mapLazy { it.username }
110-
}
112+
}.wrap()
111113

112114
override suspend fun getByUsername(username: String): MinecraftUser? = newSuspendedTransaction {
113-
MinecraftUserTable.select { MinecraftUserTable.username eq username }
115+
MinecraftUserTable.selectAll().where { MinecraftUserTable.username eq username }
114116
.firstOrNull()
115117
?.toMinecraftUser()
116118
}

proxy/src/main/kotlin/org/anvilpowered/catalyst/proxy/db/user/MinecraftUserTable.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ internal class MinecraftUserEntity(id: EntityID<UUID>) : UUIDEntity(id) {
4141
}
4242

4343
internal fun ResultRow.toMinecraftUser() = MinecraftUser(
44-
id = this[MinecraftUserTable.id].value,
44+
uuid = this[MinecraftUserTable.id].value,
4545
username = this[MinecraftUserTable.username],
4646
ipAddress = this[MinecraftUserTable.ipAddress],
4747
nickname = this[MinecraftUserTable.nickname],

proxy/src/main/kotlin/org/anvilpowered/catalyst/proxy/db/user/UserRepositoryImpl.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class UserRepositoryImpl(
5151
val user = checkNotNull(result) { "Failed to create User ${item.username}" }
5252
.single().toUser()
5353

54-
logger.info("Created new User ${user.id} with data $item")
54+
logger.info("Created new User ${user.uuid} with data $item")
5555

5656
user
5757
}
@@ -62,25 +62,25 @@ class UserRepositoryImpl(
6262
MutableRepository.PutResult(create(item), created = true)
6363
} else {
6464
// update the existing User
65-
logger.info("Found existing User ${existingUser.id} with username ${existingUser.username}")
65+
logger.info("Found existing User ${existingUser.uuid} with username ${existingUser.username}")
6666

6767
if (existingUser.email != item.email) {
68-
UserTable.update({ UserTable.id eq existingUser.id }) {
69-
logger.info("Updating email for User ${existingUser.id} from ${existingUser.email} to ${item.email}")
68+
UserTable.update({ UserTable.id eq existingUser.uuid }) {
69+
logger.info("Updating email for User ${existingUser.uuid} from ${existingUser.email} to ${item.email}")
7070
it[email] = item.email
7171
}
7272
}
7373

7474
if (existingUser.discordUserId != item.discordUserId) {
75-
UserTable.update({ UserTable.id eq existingUser.id }) {
76-
logger.info("Updating discordUserId for User ${existingUser.id} from ${existingUser.discordUserId} to ${item.discordUserId}")
75+
UserTable.update({ UserTable.id eq existingUser.uuid }) {
76+
logger.info("Updating discordUserId for User ${existingUser.uuid} from ${existingUser.discordUserId} to ${item.discordUserId}")
7777
it[discordUserId] = item.discordUserId
7878
}
7979
}
8080

8181
if (existingUser.minecraftUserId != item.minecraftUserId) {
82-
UserTable.update({ UserTable.id eq existingUser.id }) {
83-
logger.info("Updating minecraftUserId for User ${existingUser.id} from ${existingUser.minecraftUserId} to ${item.minecraftUserId}")
82+
UserTable.update({ UserTable.id eq existingUser.uuid }) {
83+
logger.info("Updating minecraftUserId for User ${existingUser.uuid} from ${existingUser.minecraftUserId} to ${item.minecraftUserId}")
8484
it[minecraftUserId] = item.minecraftUserId
8585
}
8686
}

proxy/src/main/kotlin/org/anvilpowered/catalyst/proxy/db/user/UserTable.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal class UserEntity(id: EntityID<UUID>) : UUIDEntity(id) {
4343
}
4444

4545
internal fun ResultRow.toUser() = User(
46-
id = this[UserTable.id].value,
46+
uuid = this[UserTable.id].value,
4747
username = this[UserTable.username],
4848
email = this[UserTable.email],
4949
)

0 commit comments

Comments
 (0)