From 78d3eda3db13f37cdabe23d4d089c88158e781ca Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 22 Aug 2021 10:22:57 -0700
Subject: [PATCH] Fix CB lib relocation (#6454)

---
 patches/server/Setup-Gradle-project.patch | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch
index 04254bda2a..f388ca9d3c 100644
--- a/patches/server/Setup-Gradle-project.patch
+++ b/patches/server/Setup-Gradle-project.patch
@@ -105,6 +105,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +}
 +
 +relocation {
++    // Order matters here - e.g. craftbukkit proper must be relocated before any of the libs are relocated into the cb package
++    val packageVersion = "1_17_R1"
++    relocate("org.bukkit.craftbukkit" to "org.bukkit.craftbukkit.v$packageVersion") {
++        exclude("org.bukkit.craftbukkit.Main*")
++    }
++
 +    fun cb(pack: String) = "org.bukkit.craftbukkit.libs.$pack"
 +
 +    sequenceOf(
@@ -129,11 +135,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    ).forEach { pack ->
 +        relocate(pack to cb(pack))
 +    }
-+
-+    val packageVersion = "1_17_R1"
-+    relocate("org.bukkit.craftbukkit" to "org.bukkit.craftbukkit.v$packageVersion") {
-+        exclude("org.bukkit.craftbukkit.Main*")
-+    }
 +}
 +
 +tasks.shadowJar {