Skip to content

Commit 9687bb3

Browse files
committed
[FIX] Fix multiplatform bugs
1 parent 4d41b44 commit 9687bb3

19 files changed

Lines changed: 83 additions & 55 deletions

File tree

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ plugins {
1414

1515
// klibs - core
1616
alias(libs.plugins.klibs.gradle.detekt) apply false
17-
alias(libs.plugins.klibs.gradle.detekt.compose) apply false
1817
alias(libs.plugins.klibs.gradle.dokka.root) apply false
1918
alias(libs.plugins.klibs.gradle.dokka.module) apply false
2019
alias(libs.plugins.klibs.gradle.java.version) apply false

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ makeevrserg.java.ktarget=21
1313
# Project
1414
makeevrserg.project.name=SoulKeeper
1515
makeevrserg.project.group=ru.astrainteractive.soulkeeper
16-
makeevrserg.project.version.string=1.6.0
16+
makeevrserg.project.version.string=1.6.1
1717
makeevrserg.project.description=Keep your items after death
1818
makeevrserg.project.developers=makeevrserg|Makeev Roman|makeevrserg@gmail.com
1919
makeevrserg.project.url=https://github.com/Astra-Interactive/SoulKeeper

gradle/libs.versions.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ gson = "2.13.2"
1414
guava = "33.5.0-jre"
1515
jda = "6.3.1"
1616
jda-webhook = "0.8.4"
17-
klibs-gradleplugin = "1.13.2"
17+
klibs-gradleplugin = "1.15.0"
1818
klibs-kdi = "1.4.8"
1919
klibs-kstorage = "4.5.0"
2020
klibs-mikro = "1.22.0"
@@ -26,7 +26,7 @@ kotlin-serialization = "1.10.0"
2626
kotlin-serialization-kaml = "0.104.0"
2727
kotlin-version = "2.2.0"
2828
ktor = "3.4.0"
29-
minecraft-astralibs = "3.33.0"
29+
minecraft-astralibs = "3.35.0"
3030
minecraft-bstats = "3.2.1"
3131
minecraft-bungee = "1.21-R0.5-SNAPSHOT"
3232
minecraft-essentialsx = "2.21.2"
@@ -40,6 +40,7 @@ minecraft-mcprotocollib = "1.21.7-SNAPSHOT"
4040
minecraft-mockbukkit = "4.33.2"
4141
minecraft-mojang-version = "1.20.1"
4242
minecraft-neoforgeversion = "21.1.129"
43+
minecraft-neoforged-bus = "8.0.2"
4344
minecraft-packetevents = "2.11.2"
4445
minecraft-papi = "2.12.2"
4546
minecraft-protocollib = "5.3.0"
@@ -49,7 +50,9 @@ minecraft-vault = "1.7.1"
4950
minecraft-velocity = "4.0.0-SNAPSHOT"
5051
minecraft-neoforgegradle = "7.1.20"
5152
minecraft-forgeversion = "47.2.20"
52-
minecraft-brigadier = "1.0.500"
53+
minecraft-brigadier = "1.3.10"
54+
minecraft-datafixerupper = "8.0.16"
55+
joml = "1.10.8"
5356
telegrambots = "9.4.0"
5457
tests-junit-bom = "6.0.3"
5558
tests-junit-jupiter-api = "6.0.3"
@@ -119,6 +122,7 @@ minecraft-luckperms = { module = "net.luckperms:api", version.ref = "minecraft-l
119122
minecraft-mcprotocollib = { module = "org.geysermc.mcprotocollib:protocol", version.ref = "minecraft-mcprotocollib" }
120123
minecraft-mockbukkit = { module = "com.github.MockBukkit:MockBukkit", version.ref = "minecraft-mockbukkit" }
121124
minecraft-neoforgeversion = { module = "net.neoforged:neoforge", version.ref = "minecraft-neoforgeversion" }
125+
minecraft-neoforged-bus = { module = "net.neoforged:bus", version.ref = "minecraft-neoforged-bus" }
122126
minecraft-packetevents = { module = "com.github.retrooper:packetevents-spigot", version.ref = "minecraft-packetevents" }
123127
minecraft-paper-api = { module = "io.papermc.paper:paper-api", version.ref = "minecraft-spigot" }
124128
minecraft-papi = { module = "me.clip:placeholderapi", version.ref = "minecraft-papi" }
@@ -129,6 +133,7 @@ minecraft-towny = { module = "com.palmergames.bukkit.towny:towny", version.ref =
129133
minecraft-vaultapi = { module = "com.github.MilkBowl:VaultAPI", version.ref = "minecraft-vault" }
130134
minecraft-velocity-api = { module = "com.velocitypowered:velocity-api", version.ref = "minecraft-velocity" }
131135
minecraft-brigadier = { module = "com.mojang:brigadier", version.ref = "minecraft-brigadier" }
136+
minecraft-datafixerupper = { module = "com.mojang:datafixerupper", version.ref = "minecraft-datafixerupper" }
132137
telegrambots-client = { module = "org.telegram:telegrambots-client", version.ref = "telegrambots" }
133138
telegrambots-extensions = { module = "org.telegram:telegrambots-extensions", version.ref = "telegrambots" }
134139
telegrambots-longpolling = { module = "org.telegram:telegrambots-longpolling", version.ref = "telegrambots" }
@@ -141,6 +146,7 @@ tests-mockito = { module = "org.mockito:mockito-core", version.ref = "tests-mock
141146
tests-org-testing = { module = "org.testng:testng", version.ref = "tests-org-testing" }
142147
tests-turbine = { module = "app.cash.turbine:turbine", version.ref = "tests-turbine" }
143148
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh-core" }
149+
joml = { module = "org.joml:joml", version.ref = "joml" }
144150
[plugins]
145151
gradle-buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "gradle-buildconfig" }
146152
gradle-fabric-loom = { id = "fabric-loom", version.ref = "minecraft-fabric-loom" }

instances/bukkit/build.gradle.kts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ shadowJar.configure {
100100
exclude("META-INF/rewrite/**")
101101
exclude("META-INF/services/kotlin.reflect.**")
102102
exclude("META-INF/versions/**")
103+
exclude(dependency("mysql:mysql-connector-java"))
104+
exclude(dependency("com.mysql:mysql-connector-j"))
105+
exclude(dependency("org.xerial:sqlite-jdbc"))
106+
exclude(dependency("com.mojang:brigadier"))
107+
exclude(dependency("net.kyori:.*"))
103108
}
104109
relocate("org.bstats", projectInfo.group)
105110
listOf(
@@ -113,7 +118,10 @@ shadowJar.configure {
113118
"org.intellij",
114119
"org.jetbrains.annotations",
115120
"ru.astrainteractive.klibs",
116-
"ru.astrainteractive.astralibs"
121+
"ru.astrainteractive.astralibs",
122+
"io.github.reactivecircus",
123+
"co.touchlab.stately",
124+
"google.protobuf",
117125
).forEach { pattern -> relocate(pattern, "${projectInfo.group}.$pattern") }
118126
listOf(
119127
"kotlinx",

instances/bukkit/src/main/kotlin/ru/astrainteractive/soulkeeper/di/RootModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class RootModule(plugin: LifecyclePlugin) {
5151
mainScope = coreModule.mainScope,
5252
plugin = plugin
5353
),
54+
multiplatformCommand = MultiplatformCommand(PaperMultiplatformCommands()),
5455
soulsDaoModule = soulsDaoModule,
5556
serviceModule = serviceModule,
56-
multiplatformCommand = MultiplatformCommand(PaperMultiplatformCommands()),
5757
lifecyclePlugin = plugin,
5858
)
5959

modules/command/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies {
1919
}
2020

2121
dependencies {
22-
compileOnly("org.joml:joml:1.10.8")
23-
compileOnly("com.mojang:datafixerupper:8.0.16")
24-
compileOnly("com.mojang:brigadier:1.3.10")
22+
compileOnly(libs.joml)
23+
compileOnly(libs.minecraft.datafixerupper)
24+
compileOnly(libs.minecraft.brigadier)
2525
}

modules/command/src/main/kotlin/ru/astrainteractive/soulkeeper/command/di/CommandModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import ru.astrainteractive.soulkeeper.module.souls.di.SoulsDaoModule
1313

1414
class CommandModule(
1515
private val coreModule: CoreModule,
16-
private val commandRegistrarContext: CommandRegistrarContext,
1716
private val soulsDaoModule: SoulsDaoModule,
1817
private val serviceModule: ServiceModule,
19-
private val multiplatformCommand: MultiplatformCommand<*>,
18+
private val commandRegistrarContext: CommandRegistrarContext,
19+
private val multiplatformCommand: MultiplatformCommand,
2020
private val lifecyclePlugin: Lifecycle
2121
) {
2222
val lifecycle = Lifecycle.Lambda(

modules/command/src/main/kotlin/ru/astrainteractive/soulkeeper/command/reload/SoulsReloadCommandRegistrar.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import ru.astrainteractive.astralibs.command.api.registrar.CommandRegistrarConte
66
import ru.astrainteractive.astralibs.kyori.KyoriComponentSerializer
77
import ru.astrainteractive.astralibs.kyori.unwrap
88
import ru.astrainteractive.astralibs.lifecycle.Lifecycle
9-
import ru.astrainteractive.astralibs.server.KAudience
109
import ru.astrainteractive.klibs.kstorage.api.CachedKrate
1110
import ru.astrainteractive.klibs.kstorage.util.getValue
1211
import ru.astrainteractive.soulkeeper.core.plugin.PluginPermission
@@ -15,7 +14,7 @@ import ru.astrainteractive.soulkeeper.core.plugin.PluginTranslation
1514
internal class SoulsReloadCommandRegistrar(
1615
private val lifecyclePlugin: Lifecycle,
1716
private val registrarContext: CommandRegistrarContext,
18-
private val multiplatformCommand: MultiplatformCommand<*>,
17+
private val multiplatformCommand: MultiplatformCommand,
1918
translationKrate: CachedKrate<PluginTranslation>,
2019
kyoriKrate: CachedKrate<KyoriComponentSerializer>
2120
) : KyoriComponentSerializer by kyoriKrate.unwrap() {
@@ -26,10 +25,10 @@ internal class SoulsReloadCommandRegistrar(
2625
command("skreload") {
2726
runs { ctx ->
2827
ctx.requirePermission(PluginPermission.Reload)
29-
val audience = commands.getSender(ctx) as? KAudience
30-
audience?.sendMessage(translation.general.reload.component)
28+
val audience = ctx.getSender()
29+
audience.sendMessage(translation.general.reload.component)
3130
lifecyclePlugin.onReload()
32-
audience?.sendMessage(translation.general.reloadComplete.component)
31+
audience.sendMessage(translation.general.reloadComplete.component)
3332
}
3433
}
3534
}

modules/command/src/main/kotlin/ru/astrainteractive/soulkeeper/command/soulkrate/SoulKrateCommandRegistrar.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import java.util.*
2626
@Suppress("LongParameterList")
2727
internal class SoulKrateCommandRegistrar(
2828
private val registrarContext: CommandRegistrarContext,
29-
private val multiplatformCommand: MultiplatformCommand<*>,
29+
private val multiplatformCommand: MultiplatformCommand,
3030
private val stringFormat: StringFormat,
3131
private val dataFolder: File,
3232
private val ioScope: CoroutineScope,

modules/command/src/main/kotlin/ru/astrainteractive/soulkeeper/command/souls/SoulsCommandExecutor.kt

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import kotlinx.coroutines.CoroutineScope
44
import kotlinx.coroutines.launch
55
import kotlinx.coroutines.withContext
66
import net.kyori.adventure.text.Component
7+
import ru.astrainteractive.astralibs.command.api.brigadier.sender.ConsoleKCommandSender
78
import ru.astrainteractive.astralibs.command.api.brigadier.sender.KCommandSender
9+
import ru.astrainteractive.astralibs.command.api.brigadier.sender.KPlayerKCommandSender
810
import ru.astrainteractive.astralibs.kyori.KyoriComponentSerializer
911
import ru.astrainteractive.astralibs.kyori.unwrap
10-
import ru.astrainteractive.astralibs.server.KAudience
11-
import ru.astrainteractive.astralibs.server.Locatable
1212
import ru.astrainteractive.astralibs.server.location.KLocation
1313
import ru.astrainteractive.astralibs.server.location.dist
1414
import ru.astrainteractive.astralibs.server.permission.KPermissible
15-
import ru.astrainteractive.astralibs.server.player.KPlayer
1615
import ru.astrainteractive.astralibs.server.player.OnlineKPlayer
1716
import ru.astrainteractive.astralibs.util.clickable
1817
import ru.astrainteractive.astralibs.util.isEmpty
@@ -52,27 +51,34 @@ internal class SoulsCommandExecutor(
5251
}
5352

5453
private suspend fun getFilteredSouls(sender: KCommandSender): List<DatabaseSoul> {
55-
return soulsDao.getSouls()
54+
val souls = soulsDao.getSouls()
5655
.getOrNull()
5756
.orEmpty()
58-
.filter { soul ->
59-
sender.tryCast<Locatable>()
60-
?.getLocation()
61-
?.worldName == soul.location.worldName
62-
}
63-
.filter { soul ->
64-
soul.isFree
65-
.or(sender.tryCast<KPermissible>()?.hasPermission(PluginPermission.ViewAllSouls) == true)
66-
.or(sender.tryCast<KPlayer>()?.uuid == soul.ownerUUID)
57+
return when (sender) {
58+
is KPlayerKCommandSender -> {
59+
souls
60+
.filter { soul ->
61+
sender
62+
.instance
63+
.getLocation()
64+
.worldName == soul.location.worldName
65+
}
66+
.filter { soul ->
67+
soul.isFree
68+
.or(sender.instance.hasPermission(PluginPermission.ViewAllSouls))
69+
.or(sender.instance.uuid == soul.ownerUUID)
70+
}
6771
}
72+
73+
is ConsoleKCommandSender -> souls
74+
}
6875
}
6976

7077
private fun getPageSouls(souls: List<DatabaseSoul>, page: Int): List<DatabaseSoul> {
7178
val start = page.times(SoulsCommand.PAGE_SIZE).coerceIn(0, souls.size)
72-
val end =
73-
(page * SoulsCommand.PAGE_SIZE + SoulsCommand.PAGE_SIZE).coerceAtMost(
74-
souls.size
75-
)
79+
val end = page.times(SoulsCommand.PAGE_SIZE)
80+
.plus(SoulsCommand.PAGE_SIZE)
81+
.coerceAtMost(souls.size)
7682
return if (start == end) {
7783
emptyList()
7884
} else if (end == 0) {
@@ -109,7 +115,7 @@ internal class SoulsCommandExecutor(
109115
private fun KCommandSender.canFreeSouls(soul: DatabaseSoul): Boolean {
110116
val sender = this
111117
val hasPermission = sender.tryCast<KPermissible>()?.hasPermission(PluginPermission.FreeAllSouls) == true
112-
val isOwner = sender.tryCast<KPlayer>()?.uuid == soul.ownerUUID
118+
val isOwner = sender.tryCast<KPlayerKCommandSender>()?.instance?.uuid == soul.ownerUUID
113119
if (soul.isFree) return false
114120
if (!hasPermission) return false
115121
if (!isOwner) return false
@@ -162,23 +168,25 @@ internal class SoulsCommandExecutor(
162168
is SoulsCommand.Intent.List -> {
163169
ioScope.launch {
164170
val filteredSouls = getFilteredSouls(input.sender)
171+
.also { println() }
165172
val maxPages = filteredSouls.size.div(SoulsCommand.PAGE_SIZE)
166173
val pageSouls = getPageSouls(filteredSouls, input.page)
167174
if (pageSouls.isEmpty()) {
168175
val title = translation.souls.noSoulsOnPage(input.page.plus(1)).component
169-
input.sender.tryCast<KAudience>()?.sendMessage(title)
176+
input.sender.sendMessage(title)
170177
return@launch
171178
}
172179

173-
input.sender.tryCast<KAudience>()?.sendMessage(translation.souls.listSoulsTitle.component)
180+
input.sender.sendMessage(translation.souls.listSoulsTitle.component)
174181

175182
pageSouls.forEachIndexed { i, soul ->
176183
val component = createListingItemComponent(
177184
soul = soul,
178185
page = input.page,
179186
i = i,
180187
location = input.sender
181-
.tryCast<Locatable>()
188+
.tryCast<KPlayerKCommandSender>()
189+
?.instance
182190
?.getLocation()
183191
).append(
184192
addSpace = true,
@@ -193,9 +201,9 @@ internal class SoulsCommandExecutor(
193201
soul = soul
194202
)
195203
)
196-
input.sender.tryCast<KAudience>()?.sendMessage(component)
204+
input.sender.sendMessage(component)
197205
}
198-
input.sender.tryCast<KAudience>()?.sendMessage(createPagingMessage(input, maxPages))
206+
input.sender.sendMessage(createPagingMessage(input, maxPages))
199207
}
200208
}
201209

@@ -205,22 +213,24 @@ internal class SoulsCommandExecutor(
205213
.getOrNull()
206214
?.copy(isFree = true)
207215
if (newSoul == null) {
208-
input.sender.tryCast<KAudience>()?.sendMessage(translation.souls.soulNotFound.component)
216+
input.sender.sendMessage(translation.souls.soulNotFound.component)
209217
return@launch
210218
}
211219
soulsDao.updateSoul(newSoul)
212220
.onSuccess {
213-
input.sender.tryCast<KAudience>()?.sendMessage(translation.souls.soulFreed.component)
221+
input.sender.sendMessage(translation.souls.soulFreed.component)
214222
}
215223
.onFailure {
216-
input.sender.tryCast<KAudience>()?.sendMessage(translation.souls.couldNotFreeSoul.component)
224+
input.sender.sendMessage(translation.souls.couldNotFreeSoul.component)
217225
}
218226
}
219227
}
220228

221229
is SoulsCommand.Intent.TeleportToSoul -> {
222230
ioScope.launch {
223-
val player = input.sender.tryCast<OnlineKPlayer>() ?: return@launch
231+
val player = input.sender.tryCast<KPlayerKCommandSender>()
232+
?.instance
233+
?: return@launch
224234
val location = soulsDao.getSoul(input.soulId)
225235
.getOrNull()
226236
?.location

0 commit comments

Comments
 (0)