Skip to content

Commit

Permalink
remove kotlin-gradle, fix server load
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg committed Jun 9, 2024
1 parent 7845820 commit 5a78849
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 23 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=21
# Project
makeevrserg.project.name=AstraRating
makeevrserg.project.group=ru.astrainteractive.astrarating
makeevrserg.project.version.string=1.16.0-unstable
makeevrserg.project.version.string=1.17.0
makeevrserg.project.description=Rating plugin for EmpireProjekt
makeevrserg.project.developers=makeevrserg|Makeev Roman|makeevrserg@gmail.com
makeevrserg.project.url=https://empireprojekt.ru
Expand Down
4 changes: 1 addition & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ kotlin-coroutines-coreJvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines
kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin-version" }
kotlin-serializationJson = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlin-json" }
kotlin-serializationKaml = { module = "com.charleskorn.kaml:kaml", version.ref = "kotlin-kaml" }
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-version" }

# Drivers
driver-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "driver-jdbc" }
Expand All @@ -53,7 +52,6 @@ exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "e
exposed-dao = { module = "org.jetbrains.exposed:exposed-dao", version.ref = "exposed" }
exposed-core = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" }


# Minecraft
minecraft-paper-api = { module = "io.papermc.paper:paper-api", version.ref = "minecraft-spigot" }
minecraft-spigot-api = { module = "org.spigotmc:spigot-api", version.ref = "minecraft-spigot" }
Expand Down Expand Up @@ -81,7 +79,7 @@ minecraft-astralibs-command-bukkit = { module = "ru.astrainteractive.astralibs:c
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"]
kotlin = ["kotlin-coroutines-core", "kotlin-coroutines-coreJvm", "kotlin-serialization", "kotlin-serializationJson", "kotlin-serializationKaml"]


[plugins]
Expand Down
1 change: 1 addition & 0 deletions modules/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ dependencies {
implementation(libs.minecraft.astralibs.core)
implementation(libs.klibs.kdi)
implementation(libs.klibs.mikro.core)
implementation("io.github.reactivecircus.cache4k:cache4k-jvm:0.13.0")
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package ru.astrainteractive.astrarating.core.cache

import io.github.reactivecircus.cache4k.Cache
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.kotlin.com.google.common.cache.Cache
import org.jetbrains.kotlin.com.google.common.cache.CacheBuilder
import java.util.concurrent.TimeUnit
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds

Expand All @@ -18,14 +16,14 @@ class JCache<K : Any, V : Any>(
private val update: suspend CoroutineScope.(K) -> V
) {
private val limitedDispatcher = Dispatchers.IO.limitedParallelism(1)
private val cache: Cache<K, Data<V>> = CacheBuilder
.newBuilder()
.maximumSize(maximumSize)
.expireAfterAccess(expiresAfterAccess.inWholeSeconds, TimeUnit.SECONDS)
private val cache: Cache<K, Data<V>> = Cache.Builder<K, Data<V>>()
.maximumCacheSize(maximumSize)
.expireAfterAccess(expiresAfterAccess)
.build()

private class Data<T : Any>(val data: T) {
val cachedAt: Long = System.currentTimeMillis()
val a: Any = 1

fun needUpdate(duration: Duration): Boolean {
val timePassed = System.currentTimeMillis().minus(cachedAt).milliseconds
Expand All @@ -49,7 +47,7 @@ class JCache<K : Any, V : Any>(
}

fun getIfPresent(key: K): V? {
val cacheData = cache.getIfPresent(key)
val cacheData = cache.get(key)
if (cacheData == null || cacheData.needUpdate(updateAfterAccess)) refresh(key)
return cacheData?.data
}
Expand Down
34 changes: 23 additions & 11 deletions spigot/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import ru.astrainteractive.gradleplugin.property.extension.ModelPropertyValueExt.requireProjectInfo
import ru.astrainteractive.gradleplugin.setupSpigotProcessor
import ru.astrainteractive.gradleplugin.setupSpigotShadow

plugins {
kotlin("jvm")
kotlin("plugin.serialization")
alias(libs.plugins.klibs.gradle.java.core)
id("ru.astrainteractive.gradleplugin.minecraft.multiplatform")
id("io.github.goooler.shadow")
}

dependencies {
Expand Down Expand Up @@ -46,26 +46,38 @@ minecraftMultiplatform {
implementation(projects.modules.shared.bukkitMain)
}
}
val localFolder = File("D:\\Minecraft Servers\\Servers\\esmp-configuration\\smp\\plugins")
val localFolder = File("D:\\Minecraft Servers\\Servers\\conf.smp\\smp\\plugins")
.takeIf { it.exists() }
?: File(rootDir, "jars")

setupSpigotProcessor()

setupSpigotShadow {
relocate("org.bstats", requireProjectInfo.group)
val shadowJar = tasks.named<ShadowJar>("shadowJar")
shadowJar.configure {
if (!localFolder.exists()) localFolder.mkdirs()

val projectInfo = requireProjectInfo
isReproducibleFileOrder = true
mergeServiceFiles()
dependsOn(configurations)
archiveClassifier.set(null as String?)
from(sourceSets.main.get().output)
from(project.configurations.runtimeClasspath)
relocate("org.bstats", projectInfo.group)

// listOf(
// "kotlin",
// "org.jetbrains",
// "ru.astrainteractive.astralibs"
// ).forEach { relocate(it, "${projectInfo.group}.$it") }
minimize {
exclude(dependency("org.jetbrains.exposed:exposed-jdbc:${libs.versions.exposed.get()}"))
exclude(dependency("org.jetbrains.exposed:exposed-dao:${libs.versions.exposed.get()}"))
// exclude("org.jetbrains.exposed.jdbc.ExposedConnectionImpl")
exclude(dependency(libs.exposed.jdbc.get()))
exclude(dependency(libs.exposed.dao.get()))
exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib:${libs.versions.kotlin.version.get()}"))
// exclude(dependency("org.jetbrains.exposed:exposed-jdbc:${libs.versions.exposed.get()}"))
// exclude(dependency("org.jetbrains.exposed:exposed-dao:${libs.versions.exposed.get()}"))
}
archiveVersion.set(requireProjectInfo.versionString)
archiveBaseName.set(requireProjectInfo.name)
archiveVersion.set(projectInfo.versionString)
archiveBaseName.set(projectInfo.name)
localFolder.apply { if (!exists()) parentFile.mkdirs() }
localFolder.also(destinationDirectory::set)
}

0 comments on commit 5a78849

Please sign in to comment.