From a7e0798f78c6b296645c6c5b6e3b330daef8acec Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Sat, 27 Apr 2024 17:27:32 -0700
Subject: [PATCH] Use JetBrains runtime for run tasks

allows for better runtime class redefinition

closes #10459
---
 patches/server/Setup-Gradle-project.patch | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch
index ce08f6e6b1..cf21a75732 100644
--- a/patches/server/Setup-Gradle-project.patch
+++ b/patches/server/Setup-Gradle-project.patch
@@ -107,7 +107,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    workingDir = rootProject.layout.projectDirectory
 +        .dir(providers.gradleProperty("paper.runWorkDir").getOrElse("run"))
 +        .asFile
-+    javaLauncher.set(project.javaToolchains.launcherFor(project.java.toolchain))
++    javaLauncher.set(project.javaToolchains.launcherFor {
++        languageVersion.set(JavaLanguageVersion.of(21))
++        vendor.set(JvmVendorSpec.JETBRAINS)
++    })
++    jvmArgs("-XX:+AllowEnhancedClassRedefinition", "-XX:+AllowRedefinitionToAddDeleteMethods")
 +
 +    if (rootProject.childProjects["test-plugin"] != null) {
 +        val testPluginJar = rootProject.project(":test-plugin").tasks.jar.flatMap { it.archiveFile }