From b52d90ccc90e75c69fdfba08c89cf978846c6e9f Mon Sep 17 00:00:00 2001 From: Seggan Date: Thu, 25 Jan 2024 14:10:25 -0500 Subject: [PATCH] Shrink it --- build.gradle.kts | 13 +++++++++---- .../galactifun/scripting/ScriptDef.kt | 10 +++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4e142aa..bcfced0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,11 +14,11 @@ repositories { dependencies { library(kotlin("stdlib")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0-RC2") + library("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0-RC2") - implementation(kotlin("scripting-common")) - implementation(kotlin("scripting-jvm")) - implementation(kotlin("scripting-jvm-host")) + library(kotlin("scripting-common")) + library(kotlin("scripting-jvm")) + library(kotlin("scripting-jvm-host")) compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") compileOnly("com.github.Slimefun:Slimefun4:RC-36") @@ -46,6 +46,11 @@ tasks.shadowJar { relocate("org.bstats", "io.github.addoncommunity.galactifun.bstats") relocate("co.aikar.commands", "io.github.addoncommunity.galactifun.acf") relocate("co.aikar.locales", "io.github.addoncommunity.galactifun.acf.locales") + + dependencies { + exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib")) + exclude(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk8")) + } } bukkit { diff --git a/src/main/kotlin/io/github/addoncommunity/galactifun/scripting/ScriptDef.kt b/src/main/kotlin/io/github/addoncommunity/galactifun/scripting/ScriptDef.kt index 38ac8e9..fb57454 100644 --- a/src/main/kotlin/io/github/addoncommunity/galactifun/scripting/ScriptDef.kt +++ b/src/main/kotlin/io/github/addoncommunity/galactifun/scripting/ScriptDef.kt @@ -10,12 +10,10 @@ import org.bukkit.Material import kotlin.script.experimental.annotations.KotlinScript import kotlin.script.experimental.api.* import kotlin.script.experimental.jvm.baseClassLoader -import kotlin.script.experimental.jvm.dependenciesFromCurrentContext +import kotlin.script.experimental.jvm.dependenciesFromClassloader import kotlin.script.experimental.jvm.jvm import kotlin.script.experimental.jvm.jvmTarget import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost -import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate -import kotlin.script.experimental.jvmhost.createJvmEvaluationConfigurationFromTemplate @KotlinScript( fileExtension = "planet.kts", @@ -40,7 +38,7 @@ object PlanetScriptConfig : ScriptCompilationConfiguration({ defaultImports(Material::class, BaseUniverse::class, TheUniverse::class, Earth::class, Moon::class) compilerOptions.append("-Xadd-modules=ALL-MODULE-PATH") jvm { - dependenciesFromCurrentContext(wholeClasspath = true) + dependenciesFromClassloader(classLoader = pluginInstance::class.java.classLoader, wholeClasspath = true) jvmTarget("17") } }) @@ -52,7 +50,5 @@ object PlanetScriptEval : ScriptEvaluationConfiguration({ }) fun evalScript(script: SourceCode): ResultWithDiagnostics { - val config = createJvmCompilationConfigurationFromTemplate() - val evalConfig = createJvmEvaluationConfigurationFromTemplate() - return BasicJvmScriptingHost().eval(script, config, evalConfig) + return BasicJvmScriptingHost().eval(script, PlanetScriptConfig, PlanetScriptEval) } \ No newline at end of file