Skip to content

Commit

Permalink
Various fixes (#44)
Browse files Browse the repository at this point in the history
* remove kdi

* replace astralibs orm with exposed

* fix lifecycles

* fix logs

* fix file generate

* fix yaml format

* improve slot context

* add players button

* fix detekt

* update readme

* fix merge group

* fix tests
  • Loading branch information
makeevrserg authored Oct 6, 2024
1 parent e4a5d4b commit 7fb1bb8
Show file tree
Hide file tree
Showing 89 changed files with 1,167 additions and 1,054 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Check Develop
on:
merge_group:
pull_request:
branches:
- 'develop'
Expand Down
87 changes: 85 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
# Auction plugin for EmpireProjekt.ru

## No-Lag and free!
## No-Lag, Free, Live Database reload during server runtime without lags!

<p align="center">
<img src="media/market.png" alt="drawing" width="400"/>
</p>


Advantages:

- [x] Sorting: Name,Date,Type,Player
- [x] Sorting: Name, Date, Type, Player
- [x] Grouping by players
- [x] Min and Max prices
- [x] Max amount per player
- [x] Broadcast when auction created
- [x] Sounds on click, open, sold etc.
- [x] Permissions
- [x] Customizable buttons
- [x] Fully translatable
- [x] Runtime config and database reload
- [x] Custom currency support

| Command | Description | Permission |
|:----------------------------------|:------------------------------------------------|:------------------------|
Expand All @@ -23,5 +31,80 @@ Advantages:
| ️- | Allows player to sell up to N items at one time | astra_market.sell_max.N |
|`/amarketreload` | reload plugin | astra_market.reload |

### Configuring configs

At first launch there will be created config.yml

If plugin can't read config there will be created config.default.yml. The error also will be displayed in console, so
you will understand why the config couldn't be parsed.

```yaml
auction:
use_compact_design: true
max_auction_per_player: 5
min_price: 10
max_price: 1000000
tax_percent: 0
announce: true
max_time_seconds: 604800000
# The vault id of currency you want to use
currency_id: null
sounds:
open: "ui.button.click"
close: "ui.button.click"
click: "ui.button.click"
fail: "entity.villager.no"
success: "block.note_block.chime"
sold: "block.note_block.chime"
buttons:
back:
material: "IRON_DOOR"
custom_model_data: 0
previous:
material: "PAPER"
custom_model_data: 0
next:
material: "PAPER"
custom_model_data: 0
sort:
material: "SUNFLOWER"
custom_model_data: 0
aauc:
material: "DIAMOND"
custom_model_data: 0
expred:
material: "EMERALD"
custom_model_data: 0
border:
material: "BLACK_STAINED_GLASS_PANE"
custom_model_data: 0
players_slots:
material: "PLAYER_HEAD"
custom_model_data: 0
```
### Configuring database
The database can be changed in runtime after reloading plugin.
```yaml
# There's 3 types of database
configuration:
type: "MySql"
host: "0.0.0.0"
port: 3006
user: "user_name"
password: "password"
name: "rating_database"
# Or
configuration:
type: "H2"
name: "file_name"
# Or
configuration:
type: "SQLite"
name: "file_name"
```
More plugins from AstraInteractive [AstraInteractive](https://github.com/Astra-Interactive)
<img src="https://bstats.org/signatures/bukkit/AstraMarket.svg"/>
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ plugins {
alias(libs.plugins.klibs.gradle.publication) apply false
alias(libs.plugins.klibs.gradle.rootinfo) apply false
// klibs - minecraft
alias(libs.plugins.klibs.gradle.minecraft.empty) apply false
alias(libs.plugins.klibs.gradle.minecraft.multiplatform) apply false
alias(libs.plugins.klibs.minecraft.shadow) apply false
alias(libs.plugins.klibs.minecraft.resource.processor) apply false
}

apply(plugin = "ru.astrainteractive.gradleplugin.dokka.root")
Expand Down
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=21
# Project
makeevrserg.project.name=AstraMarket
makeevrserg.project.group=ru.astrainteractive.astramarket
makeevrserg.project.version.string=1.16.15
makeevrserg.project.version.string=1.17.0
makeevrserg.project.description=Market plugin for EmpireSMP
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected]
makeevrserg.project.url=https://empireprojekt.ru
27 changes: 21 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,33 @@ driver-jdbc = "3.46.1.3" # https://github.com/xerial/sqlite-jdbc
driver-mysql = "8.0.33" # https://github.com/mysql/mysql-connector-j

# klibs
klibs-gradleplugin = "1.3.4" # https://github.com/makeevrserg/gradle-plugin
klibs-gradleplugin = "1.4.0" # https://github.com/makeevrserg/gradle-plugin
klibs-mikro = "1.8.8" # https://github.com/makeevrserg/klibs.mikro
klibs-kdi = "1.4.8" # https://github.com/makeevrserg/klibs.kdi
klibs-kstorage = "3.1.3" # https://github.com/makeevrserg/klibs.kstorage

# Minecraft
minecraft-velocity = "4.0.0-SNAPSHOT" # https://github.com/PaperMC/Velocity
minecraft-spigot = "1.21-R0.1-SNAPSHOT" # https://github.com/PaperMC/Paper
minecraft-papi = "2.11.6" # https://github.com/PlaceholderAPI/PlaceholderAPI
minecraft-protocollib = "5.1.0" # https://github.com/dmulloy2/ProtocolLib
minecraft-vault = "1.7.1" # https://github.com/MilkBowl/VaultAPI
minecraft-astralibs = "3.14.1" # https://github.com/Astra-Interactive/AstraLibs
minecraft-astralibs = "3.15.0" # https://github.com/Astra-Interactive/AstraLibs
minecraft-bstats = "3.1.0" # https://github.com/Bastian/bStats
minecraft-mockbukkit = "3.129.1" #https://github.com/MockBukkit/MockBukkit

# Exposed
ktor = "2.3.12"

# Shadow
gradle-shadow = "7.1.2" # https://github.com/johnrengelman/shadow

# BuildConfig
gradle-buildconfig = "5.5.0" # https://github.com/gmazzo/gradle-buildconfig-plugin

# Exposed
exposed = "0.55.0" # https://github.com/JetBrains/Exposed

[libraries]
# Kotlin
kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
Expand All @@ -39,6 +46,12 @@ kotlin-serializationJson = { module = "org.jetbrains.kotlinx:kotlinx-serializati
kotlin-serializationKaml = { module = "com.charleskorn.kaml:kaml", version.ref = "kotlin-kaml" }
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-version" }

# Exposed
exposed-java-time = { module = "org.jetbrains.exposed:exposed-java-time", version.ref = "exposed" }
exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "exposed" }
exposed-dao = { module = "org.jetbrains.exposed:exposed-dao", version.ref = "exposed" }
exposed-core = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" }

# Shadow
gradle-shadow = { module = "gradle.plugin.com.github.johnrengelman:shadow", version.ref = "gradle-shadow" }

Expand All @@ -63,21 +76,23 @@ minecraft-mockbukkit = { module = "com.github.MockBukkit:MockBukkit", version.re
# klibs
klibs-mikro-core = { module = "ru.astrainteractive.klibs:mikro-core", version.ref = "klibs-mikro" }
klibs-kdi = { module = "ru.astrainteractive.klibs:kdi", version.ref = "klibs-kdi" }
klibs-kstorage = { module = "ru.astrainteractive.klibs:kstorage", version.ref = "klibs-kstorage" }


# AstraLibs
minecraft-astralibs-orm = { module = "ru.astrainteractive.astralibs:orm", version.ref = "minecraft-astralibs" }
minecraft-astralibs-exposed = { module = "ru.astrainteractive.astralibs:exposed", version.ref = "minecraft-astralibs" }
minecraft-astralibs-core = { module = "ru.astrainteractive.astralibs:core", version.ref = "minecraft-astralibs" }
minecraft-astralibs-menu-bukkit = { module = "ru.astrainteractive.astralibs:menu-bukkit", version.ref = "minecraft-astralibs" }
minecraft-astralibs-core-bukkit = { module = "ru.astrainteractive.astralibs:core-bukkit", version.ref = "minecraft-astralibs" }
minecraft-astralibs-command = { module = "ru.astrainteractive.astralibs:command", version.ref = "minecraft-astralibs" }
minecraft-astralibs-command-bukkit = { module = "ru.astrainteractive.astralibs:command-bukkit", version.ref = "minecraft-astralibs" }

[bundles]
exposed = ["exposed-java-time", "exposed-jdbc", "exposed-dao", "exposed-core"]
minecraft-bukkit = ["minecraft-paper-api", "minecraft-spigot-api", "minecraft-spigot-core", "minecraft-vaultapi", "minecraft-papi"]
testing-kotlin = ["kotlin-coroutines-core", "kotlin-coroutines-coreJvm", "driver-jdbc", "driver-mysql", "kotlin-serialization", "kotlin-serializationJson"]
kotlin = ["kotlin-coroutines-core", "kotlin-coroutines-coreJvm", "kotlin-serialization", "kotlin-serializationJson", "kotlin-serializationKaml", "kotlin-gradle"]


[plugins]

# Kotlin
Expand All @@ -100,5 +115,5 @@ klibs-gradle-publication = { id = "ru.astrainteractive.gradleplugin.publication"
klibs-gradle-rootinfo = { id = "ru.astrainteractive.gradleplugin.root.info", version.ref = "klibs-gradleplugin" }

# klibs - minecraft
klibs-gradle-minecraft-empty = { id = "ru.astrainteractive.gradleplugin.minecraft.empty", version.ref = "klibs-gradleplugin" }
klibs-gradle-minecraft-multiplatform = { id = "ru.astrainteractive.gradleplugin.minecraft.multiplatform", version.ref = "klibs-gradleplugin" }
klibs-minecraft-resource-processor = { id = "ru.astrainteractive.gradleplugin.minecraft.resource-processor", version.ref = "klibs-gradleplugin" }
klibs-minecraft-shadow = { id = "ru.astrainteractive.gradleplugin.minecraft.shadow", version.ref = "klibs-gradleplugin" }
Binary file added media/market.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions modules/api-market/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ dependencies {
implementation(libs.bundles.kotlin)
// AstraLibs
implementation(libs.minecraft.astralibs.core)
implementation(libs.minecraft.astralibs.orm)
implementation(libs.klibs.kdi)
implementation(libs.minecraft.astralibs.exposed)
implementation(libs.klibs.mikro.core)
implementation(libs.bundles.exposed)
// Test
testImplementation(libs.bundles.testing.kotlin)
testImplementation(libs.tests.kotlin.test)
testImplementation("com.h2database:h2:2.2.224")
// Local
implementation(projects.modules.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ru.astrainteractive.astramarket.api.market

import ru.astrainteractive.astramarket.api.market.model.MarketSlot
import ru.astrainteractive.astramarket.api.market.model.PlayerAndSlots
import java.util.UUID

interface MarketApi {
/**
Expand Down Expand Up @@ -52,10 +53,20 @@ interface MarketApi {
* @throws Exception
*/
suspend fun countPlayerSlots(uuid: String): Int?
}

/**
* @return uuid of player who currently have active/expired slots
* @throws Exception
*/
suspend fun findPlayersWithSlots(isExpired: Boolean): List<PlayerAndSlots>
/**
* @return uuid of player who currently have active/expired slots
* @throws Exception
*/
suspend fun MarketApi.findPlayersWithSlots(isExpired: Boolean): List<PlayerAndSlots> {
return getSlots(isExpired)
.orEmpty()
.groupBy(MarketSlot::minecraftUuid)
.map { (uuid, slots) ->
PlayerAndSlots(
minecraftUUID = UUID.fromString(uuid),
slots = slots
)
}
}
Loading

0 comments on commit 7fb1bb8

Please sign in to comment.