Skip to content

Commit

Permalink
update astralibs
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg committed Jan 18, 2024
1 parent 4ca0474 commit bd9c8fa
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 39 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ makeevrserg.java.ktarget=17
# Project
makeevrserg.project.name=AstraMarket
makeevrserg.project.group=ru.astrainteractive.astramarket
makeevrserg.project.version.string=1.10.1
makeevrserg.project.version.string=1.11.0-RC1
makeevrserg.project.description=Market plugin for EmpireSMP
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected]
makeevrserg.project.url=https://empireprojekt.ru
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ minecraft-protocollib = "4.8.0"
minecraft-wg = "7.0.7"
minecraft-vault = "1.7"
minecraft-coreprotect = "21.2"
minecraft-astralibs = "2.25.2"
minecraft-astralibs = "2.28.0"
minecraft-bstats = "3.0.0"
minecraft-mockbukkit = "v1.19-SNAPSHOT"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package ru.astrainteractive.astramarket.api.market.dto

import ru.astrainteractive.astralibs.encoding.IO
import ru.astrainteractive.astralibs.encoding.model.EncodedObject

data class MarketSlot(
val id: Int,
val discordId: String?,
val minecraftUuid: String,
val time: Long,
val item: IO.ByteArray,
val item: EncodedObject.ByteArray,
val price: Float,
var expired: Boolean,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.astrainteractive.astramarket.api.market.mapping

import ru.astrainteractive.astralibs.encoding.IO
import ru.astrainteractive.astralibs.encoding.model.EncodedObject
import ru.astrainteractive.astramarket.api.market.dto.MarketSlot
import ru.astrainteractive.astramarket.db.market.entity.Auction
import ru.astrainteractive.klibs.mikro.core.domain.Mapper
Expand All @@ -15,7 +15,7 @@ internal class AuctionMapperImpl : AuctionMapper {
discordId = it.discordId,
minecraftUuid = it.minecraftUuid,
time = it.time,
item = IO.ByteArray(it.item),
item = EncodedObject.ByteArray(it.item),
price = it.price,
expired = it.expired == 1
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package ru.astrainteractive.astramarket.api.market

import kotlinx.coroutines.runBlocking
import ru.astrainteractive.astralibs.encoding.IO
import ru.astrainteractive.astralibs.encoding.model.EncodedObject
import ru.astrainteractive.astralibs.orm.DBConnection
import ru.astrainteractive.astralibs.orm.DBSyntax
import ru.astrainteractive.astramarket.api.market.MarketApi
import ru.astrainteractive.astramarket.db.market.entity.AuctionTable
import ru.astrainteractive.astramarket.di.ApiMarketModule
import ru.astrainteractive.klibs.mikro.core.dispatchers.DefaultKotlinDispatchers
Expand All @@ -14,7 +15,7 @@ import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals

class AuctionsTests {
class MarketApiTest {
private val moduleFactory = {
ApiMarketModule.Default(
dispatchers = DefaultKotlinDispatchers,
Expand All @@ -32,7 +33,7 @@ class AuctionsTests {
discordId = UUID.randomUUID().toString(),
minecraftUuid = UUID.randomUUID().toString(),
time = System.currentTimeMillis(),
item = IO.ByteArray(ByteArray(0)),
item = EncodedObject.ByteArray(ByteArray(0)),
price = Random.nextInt().toFloat(),
expired = false
)
Expand All @@ -43,7 +44,7 @@ class AuctionsTests {
val module = moduleFactory.invoke()
module.database.openConnection()
AuctionTable.create(module.database)
this@AuctionsTests.module = module
this@MarketApiTest.module = module
}

@AfterTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import ru.astrainteractive.astralibs.async.AsyncComponent
import ru.astrainteractive.astralibs.economy.EconomyProvider
import ru.astrainteractive.astralibs.filemanager.impl.JVMResourceFileManager
import ru.astrainteractive.astralibs.lifecycle.Lifecycle
import ru.astrainteractive.astralibs.serialization.SerializerExt.parse
import ru.astrainteractive.astralibs.serialization.SerializerExt.writeIntoFile
import ru.astrainteractive.astralibs.serialization.YamlSerializer
import ru.astrainteractive.astramarket.core.PluginConfig
import ru.astrainteractive.astramarket.core.Translation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package ru.astrainteractive.astramarket.data.bridge
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.inventory.ItemStack
import ru.astrainteractive.astralibs.encoding.Encoder
import ru.astrainteractive.astralibs.encoding.encoder.ObjectEncoder
import ru.astrainteractive.astralibs.permission.BukkitPermissibleExt.toPermissible
import ru.astrainteractive.astramarket.api.market.dto.MarketSlot
import ru.astrainteractive.astramarket.core.PluginPermission
import java.util.UUID

@Suppress("TooManyFunctions")
class BukkitAuctionsBridge(
private val encoder: Encoder,
private val encoder: ObjectEncoder,
) : AuctionsBridge {
private fun MarketSlot.itemStack(serializer: Encoder): ItemStack {
private fun MarketSlot.itemStack(serializer: ObjectEncoder): ItemStack {
return serializer.fromByteArray(item)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.astrainteractive.astramarket.data.di

import ru.astrainteractive.astralibs.encoding.Encoder
import ru.astrainteractive.astralibs.encoding.encoder.ObjectEncoder
import ru.astrainteractive.astralibs.serialization.KyoriComponentSerializer
import ru.astrainteractive.astramarket.data.bridge.AuctionsBridge
import ru.astrainteractive.astramarket.data.bridge.BukkitAuctionsBridge
Expand All @@ -10,7 +10,7 @@ import ru.astrainteractive.klibs.kdi.Provider
import ru.astrainteractive.klibs.kdi.getValue

class BukkitSharedDataModule(
encoder: Encoder,
encoder: ObjectEncoder,
stringSerializer: KyoriComponentSerializer,
) : SharedDataModule {
override val auctionBridge: AuctionsBridge by Provider {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package ru.astrainteractive.astramarket.domain.di

import ru.astrainteractive.astralibs.encoding.Encoder
import ru.astrainteractive.astralibs.encoding.encoder.ObjectEncoder
import ru.astrainteractive.astramarket.domain.usecase.BukkitSortAuctionsUseCase
import ru.astrainteractive.astramarket.domain.usecase.SortAuctionsUseCase
import ru.astrainteractive.klibs.kdi.Provider
import ru.astrainteractive.klibs.kdi.getValue

class BukkitSharedDomainModule(encoder: Encoder) : PlatformSharedDomainModule {
class BukkitSharedDomainModule(encoder: ObjectEncoder) : PlatformSharedDomainModule {
override val sortAuctionsUseCase: SortAuctionsUseCase by Provider {
BukkitSortAuctionsUseCase(
encoder = encoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package ru.astrainteractive.astramarket.domain.usecase

import org.bukkit.Bukkit
import org.bukkit.inventory.ItemStack
import ru.astrainteractive.astralibs.encoding.Encoder
import ru.astrainteractive.astralibs.encoding.encoder.ObjectEncoder
import ru.astrainteractive.astramarket.api.market.dto.MarketSlot
import ru.astrainteractive.astramarket.domain.model.AuctionSort
import java.util.UUID

class BukkitSortAuctionsUseCase(private val encoder: Encoder) : SortAuctionsUseCase {
private fun MarketSlot.itemStack(serializer: Encoder): ItemStack {
class BukkitSortAuctionsUseCase(private val encoder: ObjectEncoder) : SortAuctionsUseCase {
private fun MarketSlot.itemStack(serializer: ObjectEncoder): ItemStack {
return serializer.fromByteArray(
item
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ru.astrainteractive.astramarket.domain.usecase

import ru.astrainteractive.astralibs.economy.EconomyProvider
import ru.astrainteractive.astralibs.string.replace
import ru.astrainteractive.astralibs.string.StringDescExt.replace
import ru.astrainteractive.astramarket.api.market.MarketApi
import ru.astrainteractive.astramarket.api.market.dto.MarketSlot
import ru.astrainteractive.astramarket.core.PluginConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.astrainteractive.astramarket.domain.usecase

import ru.astrainteractive.astralibs.string.replace
import ru.astrainteractive.astralibs.string.StringDescExt.replace
import ru.astrainteractive.astramarket.api.market.MarketApi
import ru.astrainteractive.astramarket.api.market.dto.MarketSlot
import ru.astrainteractive.astramarket.core.PluginConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.astrainteractive.astramarket.domain.usecase

import ru.astrainteractive.astralibs.string.replace
import ru.astrainteractive.astralibs.string.StringDescExt.replace
import ru.astrainteractive.astramarket.api.market.MarketApi
import ru.astrainteractive.astramarket.api.market.dto.MarketSlot
import ru.astrainteractive.astramarket.core.Translation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ru.astrainteractive.astramarket.command.auction.di

import kotlinx.coroutines.CoroutineScope
import org.bukkit.plugin.java.JavaPlugin
import ru.astrainteractive.astralibs.encoding.Encoder
import ru.astrainteractive.astralibs.encoding.encoder.ObjectEncoder
import ru.astrainteractive.astralibs.serialization.KyoriComponentSerializer
import ru.astrainteractive.astramarket.core.Translation
import ru.astrainteractive.astramarket.di.RootModule
Expand All @@ -17,7 +17,7 @@ interface AuctionCommandDependencies {
val kyoriComponentSerializer: KyoriComponentSerializer
val translation: Translation
val router: GuiRouter
val encoder: Encoder
val encoder: ObjectEncoder
val scope: CoroutineScope
val dispatchers: KotlinDispatchers
val createAuctionUseCase: CreateAuctionUseCase
Expand All @@ -29,7 +29,7 @@ interface AuctionCommandDependencies {
override val router: GuiRouter by Provider {
rootModule.auctionGuiModule.router
}
override val encoder: Encoder by Provider {
override val encoder: ObjectEncoder by Provider {
rootModule.bukkitCoreModule.encoder.value
}
override val scope: CoroutineScope by rootModule.coreModule.scope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.astrainteractive.astramarket.di

import ru.astrainteractive.astralibs.encoding.Encoder
import ru.astrainteractive.astralibs.encoding.encoder.ObjectEncoder
import ru.astrainteractive.astralibs.event.EventListener
import ru.astrainteractive.astralibs.lifecycle.Lifecycle
import ru.astrainteractive.astralibs.logging.Logger
Expand All @@ -14,7 +14,7 @@ interface BukkitCoreModule {
val lifecycle: Lifecycle

val plugin: Lateinit<AstraMarket>
val encoder: Single<Encoder>
val encoder: Single<ObjectEncoder>

val inventoryClickEventListener: Single<EventListener>
val logger: Single<Logger>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ru.astrainteractive.astramarket.di.impl

import org.bstats.bukkit.Metrics
import ru.astrainteractive.astralibs.encoding.BukkitIOStreamProvider
import ru.astrainteractive.astralibs.encoding.Encoder
import ru.astrainteractive.astralibs.encoding.encoder.BukkitObjectEncoder
import ru.astrainteractive.astralibs.encoding.encoder.ObjectEncoder
import ru.astrainteractive.astralibs.event.EventListener
import ru.astrainteractive.astralibs.lifecycle.Lifecycle
import ru.astrainteractive.astralibs.logging.JUtilFileLogger
Expand All @@ -22,8 +22,8 @@ class BukkitCoreModuleImpl : BukkitCoreModule {

override val plugin: Lateinit<AstraMarket> = Lateinit<AstraMarket>()

override val encoder: Single<Encoder> = Single {
Encoder(BukkitIOStreamProvider)
override val encoder: Single<ObjectEncoder> = Single {
BukkitObjectEncoder()
}

override val inventoryClickEventListener: Single<EventListener> = Single {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ru.astrainteractive.astralibs.menu.menu.editMeta
import ru.astrainteractive.astralibs.menu.menu.setIndex
import ru.astrainteractive.astralibs.menu.menu.setItemStack
import ru.astrainteractive.astralibs.menu.menu.setOnClickListener
import ru.astrainteractive.astralibs.string.replace
import ru.astrainteractive.astralibs.string.StringDescExt.replace
import ru.astrainteractive.astramarket.api.market.dto.MarketSlot
import ru.astrainteractive.astramarket.presentation.AuctionComponent
import ru.astrainteractive.astramarket.presentation.base.AbstractAuctionGui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import ru.astrainteractive.astralibs.menu.menu.setIndex
import ru.astrainteractive.astralibs.menu.menu.setItemStack
import ru.astrainteractive.astralibs.menu.menu.setOnClickListener
import ru.astrainteractive.astralibs.string.StringDesc
import ru.astrainteractive.astralibs.string.replace
import ru.astrainteractive.astralibs.string.StringDescExt.replace
import ru.astrainteractive.astramarket.presentation.AuctionComponent
import ru.astrainteractive.astramarket.presentation.base.di.AuctionGuiDependencies
import ru.astrainteractive.astramarket.presentation.util.ItemStackExt.playSound
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.astrainteractive.astramarket.presentation.base.di

import ru.astrainteractive.astralibs.encoding.Encoder
import ru.astrainteractive.astralibs.encoding.encoder.ObjectEncoder
import ru.astrainteractive.astralibs.serialization.KyoriComponentSerializer
import ru.astrainteractive.astramarket.core.PluginConfig
import ru.astrainteractive.astramarket.core.Translation
Expand All @@ -18,7 +18,7 @@ interface AuctionGuiDependencies {
val translation: Translation
val dispatchers: KotlinDispatchers
val sortTranslationMapping: AuctionSortTranslationMapping
val serializer: Encoder
val serializer: ObjectEncoder
val kyoriComponentSerializer: KyoriComponentSerializer
val router: GuiRouter

Expand All @@ -34,7 +34,7 @@ interface AuctionGuiDependencies {
override val sortTranslationMapping: AuctionSortTranslationMapping by Provider {
sharedDomainModule.auctionSortTranslationMapping
}
override val serializer: Encoder by bukkitCoreModule.encoder
override val serializer: ObjectEncoder by bukkitCoreModule.encoder
override val kyoriComponentSerializer: KyoriComponentSerializer by bukkitCoreModule.kyoriComponentSerializer
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ru.astrainteractive.astralibs.menu.menu.editMeta
import ru.astrainteractive.astralibs.menu.menu.setIndex
import ru.astrainteractive.astralibs.menu.menu.setItemStack
import ru.astrainteractive.astralibs.menu.menu.setOnClickListener
import ru.astrainteractive.astralibs.string.replace
import ru.astrainteractive.astralibs.string.StringDescExt.replace
import ru.astrainteractive.astramarket.api.market.dto.MarketSlot
import ru.astrainteractive.astramarket.presentation.AuctionComponent
import ru.astrainteractive.astramarket.presentation.base.AbstractAuctionGui
Expand Down

0 comments on commit bd9c8fa

Please sign in to comment.