Skip to content

Commit bc96fff

Browse files
authored
update dependencies (#121)
* update dependencies * Update gradle.properties
1 parent 1dd789b commit bc96fff

15 files changed

Lines changed: 137 additions & 106 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ makeevrserg.java.ktarget=21
66
# Project
77
makeevrserg.project.name=AstraMarket
88
makeevrserg.project.group=ru.astrainteractive.astramarket
9-
makeevrserg.project.version.string=1.22.0
9+
makeevrserg.project.version.string=1.22.1
1010
makeevrserg.project.description=Market plugin for EmpireSMP
1111
makeevrserg.project.developers=makeevrserg|Makeev Roman|makeevrserg@gmail.com
1212
makeevrserg.project.url=https://empireprojekt.ru

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jda-webhook = "0.8.4"
1717
klibs-gradleplugin = "1.13.2"
1818
klibs-kdi = "1.4.8"
1919
klibs-kstorage = "4.5.0"
20-
klibs-mikro = "1.21.0"
20+
klibs-mikro = "1.22.0"
2121
kotlin-benchmark = "0.4.16"
2222
kotlin-coroutines = "1.10.2"
2323
kotlin-datetime = "0.7.1-0.6.x-compat"
@@ -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.31.3"
29+
minecraft-astralibs = "3.33.0"
3030
minecraft-bstats = "3.2.1"
3131
minecraft-bungee = "1.21-R0.5-SNAPSHOT"
3232
minecraft-essentialsx = "2.21.2"

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package ru.astrainteractive.astramarket.di
33
import org.bukkit.Bukkit
44
import org.bukkit.entity.Player
55
import org.bukkit.event.HandlerList
6+
import ru.astrainteractive.astralibs.command.api.brigadier.command.MultiplatformCommand
7+
import ru.astrainteractive.astralibs.command.api.brigadier.command.PaperMultiplatformCommands
8+
import ru.astrainteractive.astralibs.command.api.registrar.PaperCommandRegistrarContext
69
import ru.astrainteractive.astralibs.lifecycle.Lifecycle
710
import ru.astrainteractive.astralibs.lifecycle.LifecyclePlugin
811
import ru.astrainteractive.astramarket.command.di.CommandModule
@@ -58,7 +61,12 @@ internal class RootModule(
5861
coreModule = coreModule,
5962
bukkitCoreModule = coreModule,
6063
routerModule = routerModule,
61-
marketViewModule = marketViewModule
64+
marketViewModule = marketViewModule,
65+
multiplatformCommand = MultiplatformCommand(PaperMultiplatformCommands()),
66+
commandRegistrarContext = PaperCommandRegistrarContext(
67+
mainScope = coreModule.mainScope,
68+
plugin = plugin
69+
),
6270
)
6371

6472
val workerModule: WorkerModule = WorkerModule.Default(

modules/command-bukkit/src/main/kotlin/ru/astrainteractive/astramarket/command/auction/AuctionCommand.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
package ru.astrainteractive.astramarket.command.auction
22

3-
import org.bukkit.entity.Player
43
import org.bukkit.inventory.ItemStack
4+
import ru.astrainteractive.astralibs.server.player.OnlineKPlayer
55
import java.util.UUID
66

77
internal interface AuctionCommand {
88
sealed interface Result {
99
class OpenSlots(
10-
val player: Player,
10+
val player: OnlineKPlayer,
1111
val isExpired: Boolean,
1212
val targetPlayerUUID: UUID?
1313
) : Result
1414

15-
class OpenPlayers(val player: Player, val isExpired: Boolean) : Result
15+
class OpenPlayers(
16+
val player: OnlineKPlayer,
17+
val isExpired: Boolean
18+
) : Result
19+
1620
class Sell(
17-
val player: Player,
21+
val player: OnlineKPlayer,
1822
val itemInstance: ItemStack,
1923
val amount: Int,
2024
val price: Float

modules/command-bukkit/src/main/kotlin/ru/astrainteractive/astramarket/command/auction/AuctionCommandExecutor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ internal class AuctionCommandExecutor(
6565
withContext(dispatchers.Main) { itemInstance.amount -= calculatedAmount }
6666
val marketSlot = MarketSlot(
6767
id = -1,
68-
minecraftUuid = input.player.uniqueId.toString(),
68+
minecraftUuid = input.player.uuid.toString(),
6969
time = System.currentTimeMillis(),
7070
item = encodedItem,
7171
price = input.price,
@@ -74,7 +74,7 @@ internal class AuctionCommandExecutor(
7474
)
7575
val param = CreateAuctionUseCase.Params(
7676
marketSlot = marketSlot,
77-
playerUUID = input.player.uniqueId,
77+
playerUUID = input.player.uuid,
7878
)
7979
val useCaseResult = createAuctionUseCase.invoke(param)
8080
withContext(dispatchers.Main) {

modules/command-bukkit/src/main/kotlin/ru/astrainteractive/astramarket/command/auction/AuctionCommandFactory.kt

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,80 @@ package ru.astrainteractive.astramarket.command.auction
22

33
import com.mojang.brigadier.arguments.FloatArgumentType
44
import com.mojang.brigadier.arguments.IntegerArgumentType
5-
import com.mojang.brigadier.tree.LiteralCommandNode
6-
import io.papermc.paper.command.brigadier.CommandSourceStack
7-
import ru.astrainteractive.astralibs.command.api.util.argument
8-
import ru.astrainteractive.astralibs.command.api.util.command
9-
import ru.astrainteractive.astralibs.command.api.util.literal
10-
import ru.astrainteractive.astralibs.command.api.util.requireArgument
11-
import ru.astrainteractive.astralibs.command.api.util.requirePlayer
12-
import ru.astrainteractive.astralibs.command.api.util.runs
5+
import com.mojang.brigadier.builder.LiteralArgumentBuilder
6+
import ru.astrainteractive.astralibs.command.api.brigadier.command.MultiplatformCommand
137
import ru.astrainteractive.astralibs.kyori.KyoriComponentSerializer
148
import ru.astrainteractive.astralibs.kyori.unwrap
9+
import ru.astrainteractive.astralibs.server.player.BukkitOnlineKPlayer
1510
import ru.astrainteractive.astramarket.command.errorhandler.BrigadierErrorHandler
1611
import ru.astrainteractive.klibs.kstorage.api.CachedKrate
12+
import ru.astrainteractive.klibs.mikro.core.util.cast
1713

1814
internal class AuctionCommandFactory(
19-
kyori: CachedKrate<KyoriComponentSerializer>,
2015
private val executor: AuctionCommandExecutor,
21-
private val errorHandler: BrigadierErrorHandler
22-
) : KyoriComponentSerializer by kyori.unwrap() {
16+
private val errorHandler: BrigadierErrorHandler,
17+
private val multiplatformCommand: MultiplatformCommand<*>,
18+
kyoriKrate: CachedKrate<KyoriComponentSerializer>
19+
) : KyoriComponentSerializer by kyoriKrate.unwrap() {
2320

2421
@Suppress("LongMethod")
25-
private fun create(alias: String): LiteralCommandNode<CommandSourceStack> {
26-
return command(alias) {
27-
literal("sell") {
28-
argument("price", FloatArgumentType.floatArg(0f, Float.MAX_VALUE)) { priceArg ->
29-
argument("amount", IntegerArgumentType.integer(0, Int.MAX_VALUE)) { amountArg ->
22+
private fun create(alias: String): LiteralArgumentBuilder<*> {
23+
return with(multiplatformCommand) {
24+
command(alias) {
25+
literal("sell") {
26+
argument("price", FloatArgumentType.floatArg(0f, Float.MAX_VALUE)) { priceArg ->
27+
argument("amount", IntegerArgumentType.integer(0, Int.MAX_VALUE)) { amountArg ->
28+
runs(errorHandler::handle) { ctx ->
29+
val player = ctx.requirePlayer()
30+
AuctionCommand.Result.Sell(
31+
player = player,
32+
itemInstance = player
33+
.cast<BukkitOnlineKPlayer>()
34+
.instance
35+
.inventory
36+
.itemInMainHand,
37+
amount = ctx.requireArgument(amountArg),
38+
price = ctx.requireArgument(priceArg)
39+
).run(executor::execute)
40+
}
41+
}
3042
runs(errorHandler::handle) { ctx ->
3143
val player = ctx.requirePlayer()
3244
AuctionCommand.Result.Sell(
3345
player = player,
3446
itemInstance = player
47+
.cast<BukkitOnlineKPlayer>()
48+
.instance
3549
.inventory
3650
.itemInMainHand,
37-
amount = ctx.requireArgument(amountArg),
51+
amount = 1,
3852
price = ctx.requireArgument(priceArg)
3953
).run(executor::execute)
4054
}
4155
}
56+
}
57+
literal("players") {
4258
runs(errorHandler::handle) { ctx ->
4359
val player = ctx.requirePlayer()
44-
AuctionCommand.Result.Sell(
60+
AuctionCommand.Result.OpenPlayers(
4561
player = player,
46-
itemInstance = player
47-
.inventory
48-
.itemInMainHand,
49-
amount = 1,
50-
price = ctx.requireArgument(priceArg)
62+
isExpired = false
5163
).run(executor::execute)
5264
}
5365
}
54-
}
55-
literal("players") {
5666
runs(errorHandler::handle) { ctx ->
5767
val player = ctx.requirePlayer()
58-
AuctionCommand.Result.OpenPlayers(
68+
AuctionCommand.Result.OpenSlots(
5969
player = player,
60-
isExpired = false
70+
isExpired = false,
71+
targetPlayerUUID = null
6172
).run(executor::execute)
6273
}
6374
}
64-
runs(errorHandler::handle) { ctx ->
65-
val player = ctx.requirePlayer()
66-
AuctionCommand.Result.OpenSlots(
67-
player = player,
68-
isExpired = false,
69-
targetPlayerUUID = null
70-
).run(executor::execute)
71-
}
72-
}.build()
75+
}
7376
}
7477

75-
fun create(): List<LiteralCommandNode<CommandSourceStack>> {
78+
fun create(): List<LiteralArgumentBuilder<*>> {
7679
return listOf("market", "ah", "auctionhouse", "aauc", "amarket")
7780
.map(::create)
7881
}

modules/command-bukkit/src/main/kotlin/ru/astrainteractive/astramarket/command/di/CommandModule.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ru.astrainteractive.astramarket.command.di
22

3-
import ru.astrainteractive.astralibs.command.api.registrar.PaperCommandRegistrarContext
3+
import ru.astrainteractive.astralibs.command.api.brigadier.command.MultiplatformCommand
4+
import ru.astrainteractive.astralibs.command.api.registrar.CommandRegistrarContext
45
import ru.astrainteractive.astralibs.lifecycle.Lifecycle
56
import ru.astrainteractive.astramarket.command.auction.AuctionCommandExecutor
67
import ru.astrainteractive.astramarket.command.auction.AuctionCommandFactory
@@ -18,32 +19,33 @@ interface CommandModule {
1819
coreModule: CoreModule,
1920
bukkitCoreModule: BukkitCoreModule,
2021
routerModule: RouterModule,
21-
marketViewModule: MarketViewModule
22+
marketViewModule: MarketViewModule,
23+
private val commandRegistrarContext: CommandRegistrarContext,
24+
private val multiplatformCommand: MultiplatformCommand<*>,
2225
) : CommandModule {
2326
private val errorHandler = BrigadierErrorHandler(
2427
kyoriComponentSerializer = bukkitCoreModule.kyoriComponentSerializer,
25-
translationKrate = coreModule.pluginTranslationKrate
26-
)
27-
private val commandRegistrar = PaperCommandRegistrarContext(
28-
mainScope = coreModule.mainScope,
29-
plugin = bukkitCoreModule.plugin
28+
translationKrate = coreModule.pluginTranslationKrate,
29+
multiplatformCommand = multiplatformCommand
3030
)
3131
private val reloadCommandFactory = ReloadCommandFactory(
3232
plugin = bukkitCoreModule.plugin,
3333
translationKrate = coreModule.pluginTranslationKrate,
3434
kyori = bukkitCoreModule.kyoriComponentSerializer,
35-
errorHandler = errorHandler
35+
errorHandler = errorHandler,
36+
multiplatformCommand = multiplatformCommand
3637
)
3738
private val auctionCommandFactory = AuctionCommandFactory(
38-
kyori = bukkitCoreModule.kyoriComponentSerializer,
39+
kyoriKrate = bukkitCoreModule.kyoriComponentSerializer,
3940
errorHandler = errorHandler,
4041
executor = AuctionCommandExecutor(
4142
router = routerModule.router,
4243
dispatchers = coreModule.dispatchers,
4344
createAuctionUseCase = marketViewModule.marketViewDomainModule.createAuctionUseCase,
4445
ioScope = coreModule.ioScope,
4546
itemStackEncoder = bukkitCoreModule.itemStackEncoder,
46-
)
47+
),
48+
multiplatformCommand = multiplatformCommand,
4749
)
4850

4951
override val lifecycle: Lifecycle by lazy {
@@ -52,7 +54,7 @@ interface CommandModule {
5254
buildList {
5355
addAll(auctionCommandFactory.create())
5456
add(reloadCommandFactory.create())
55-
}.onEach(commandRegistrar::registerWhenReady)
57+
}.onEach(commandRegistrarContext::registerWhenReady)
5658
}
5759
)
5860
}

modules/command-bukkit/src/main/kotlin/ru/astrainteractive/astramarket/command/errorhandler/BrigadierErrorHandler.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
package ru.astrainteractive.astramarket.command.errorhandler
22

33
import com.mojang.brigadier.context.CommandContext
4-
import io.papermc.paper.command.brigadier.CommandSourceStack
4+
import ru.astrainteractive.astralibs.command.api.brigadier.command.MultiplatformCommand
55
import ru.astrainteractive.astralibs.command.api.exception.NoPermissionException
66
import ru.astrainteractive.astralibs.kyori.KyoriComponentSerializer
77
import ru.astrainteractive.astralibs.kyori.unwrap
8+
import ru.astrainteractive.astralibs.server.KAudience
89
import ru.astrainteractive.astramarket.core.PluginTranslation
910
import ru.astrainteractive.klibs.kstorage.api.CachedKrate
1011
import ru.astrainteractive.klibs.kstorage.util.getValue
1112
import ru.astrainteractive.klibs.mikro.core.logging.JUtiltLogger
1213
import ru.astrainteractive.klibs.mikro.core.logging.Logger
14+
import ru.astrainteractive.klibs.mikro.core.util.tryCast
1315

1416
class BrigadierErrorHandler(
1517
kyoriComponentSerializer: CachedKrate<KyoriComponentSerializer>,
16-
translationKrate: CachedKrate<PluginTranslation>
18+
translationKrate: CachedKrate<PluginTranslation>,
19+
private val multiplatformCommand: MultiplatformCommand<*>,
1720
) : Logger by JUtiltLogger("AstraMarket-ErrorHandler").withoutParentHandlers(),
1821
KyoriComponentSerializer by kyoriComponentSerializer.unwrap() {
1922
private val translation by translationKrate
2023

21-
fun handle(ctx: CommandContext<CommandSourceStack>, throwable: Throwable) {
22-
when (throwable) {
23-
is NoPermissionException -> {
24-
translation.general.noPermissions.component
25-
.run(ctx.source.sender::sendMessage)
26-
}
24+
fun handle(ctx: CommandContext<*>, throwable: Throwable) {
25+
with(multiplatformCommand) {
26+
when (throwable) {
27+
is NoPermissionException -> {
28+
commands.getSender(ctx)
29+
.tryCast<KAudience>()
30+
?.sendMessage(translation.general.noPermissions.component)
31+
}
2732

28-
else -> {
29-
error(throwable) { "Unhandled exception: ${throwable.message}" }
33+
else -> {
34+
error(throwable) { "Unhandled exception: ${throwable.message}" }
35+
}
3036
}
3137
}
3238
}
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
11
package ru.astrainteractive.astramarket.command.reload
22

3-
import com.mojang.brigadier.tree.LiteralCommandNode
4-
import io.papermc.paper.command.brigadier.CommandSourceStack
5-
import ru.astrainteractive.astralibs.command.api.util.command
6-
import ru.astrainteractive.astralibs.command.api.util.requirePermission
7-
import ru.astrainteractive.astralibs.command.api.util.runs
3+
import com.mojang.brigadier.builder.LiteralArgumentBuilder
4+
import ru.astrainteractive.astralibs.command.api.brigadier.command.MultiplatformCommand
85
import ru.astrainteractive.astralibs.kyori.KyoriComponentSerializer
96
import ru.astrainteractive.astralibs.kyori.unwrap
107
import ru.astrainteractive.astralibs.lifecycle.Lifecycle
8+
import ru.astrainteractive.astralibs.server.KAudience
119
import ru.astrainteractive.astramarket.command.errorhandler.BrigadierErrorHandler
1210
import ru.astrainteractive.astramarket.core.PluginPermission
1311
import ru.astrainteractive.astramarket.core.PluginTranslation
1412
import ru.astrainteractive.klibs.kstorage.api.CachedKrate
1513
import ru.astrainteractive.klibs.kstorage.util.getValue
14+
import ru.astrainteractive.klibs.mikro.core.util.tryCast
1615

1716
class ReloadCommandFactory(
1817
private val plugin: Lifecycle,
1918
private val errorHandler: BrigadierErrorHandler,
2019
translationKrate: CachedKrate<PluginTranslation>,
21-
kyori: CachedKrate<KyoriComponentSerializer>
20+
kyori: CachedKrate<KyoriComponentSerializer>,
21+
private val multiplatformCommand: MultiplatformCommand<*>,
2222
) : KyoriComponentSerializer by kyori.unwrap() {
2323
private val translation by translationKrate
2424

25-
fun create(): LiteralCommandNode<CommandSourceStack> {
26-
return command("amarketreload") {
27-
runs(errorHandler::handle) { ctx ->
28-
ctx.requirePermission(PluginPermission.Reload)
29-
translation.general.reloadStarted
30-
.let(::toComponent)
31-
.run(ctx.source.sender::sendMessage)
32-
plugin.onReload()
33-
translation.general.reloadSuccess
34-
.let(::toComponent)
35-
.run(ctx.source.sender::sendMessage)
25+
fun create(): LiteralArgumentBuilder<*> {
26+
return with(multiplatformCommand) {
27+
command("amarketreload") {
28+
runs(errorHandler::handle) { ctx ->
29+
ctx.requirePermission(PluginPermission.Reload)
30+
ctx.getSender()
31+
.tryCast<KAudience>()
32+
?.sendMessage(translation.general.reloadStarted.component)
33+
plugin.onReload()
34+
ctx.getSender()
35+
.tryCast<KAudience>()
36+
?.sendMessage(translation.general.reloadSuccess.component)
37+
}
3638
}
37-
}.build()
39+
}
3840
}
3941
}

modules/core/src/main/kotlin/ru/astrainteractive/astramarket/core/PluginPermission.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ru.astrainteractive.astramarket.core
22

3-
import ru.astrainteractive.astralibs.permission.Permission
3+
import ru.astrainteractive.astralibs.server.permission.Permission
44

55
sealed class PluginPermission(override val value: String) : Permission {
66
data object Reload : PluginPermission("astra_market.reload")

0 commit comments

Comments
 (0)